Skip to content

Commit

Permalink
#10 old exceptions removed
Browse files Browse the repository at this point in the history
  • Loading branch information
lastorel committed Mar 29, 2022
1 parent b6d4ec5 commit f01e7fe
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions pytion/query.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

import json
import logging
from urllib.parse import urlencode
from typing import Dict, Optional, Any, Union
Expand All @@ -16,53 +15,6 @@
logger = logging.getLogger(__name__)


class RequestError(Exception):
def __init__(self, message):
req = message

if req.status_code == 404:
message = "The requested url: {} could not be found.".format(req.url)
else:
try:
message = "The request failed with code {} {}: {}".format(
req.status_code, req.reason, req.json()
)
except ValueError:
message = (
"The request failed with code {} {} but more specific "
"details were not returned in json.".format(
req.status_code, req.reason
)
)

super(RequestError, self).__init__(message)
self.req = req
self.request_body = req.request.body
self.base = req.url
self.error = req.text


class ContentError(Exception):
"""Content Exception
If the API URL does not point to a valid Notion API, the server may
return a valid response code, but the content is not json. This
exception is raised in those cases.
"""

def __init__(self, message):
req = message

message = (
"The server returned invalid (non-json) data. Maybe not a Notion server?"
)

super(ContentError, self).__init__(message)
self.req = req
self.request_body = req.request.body
self.base = req.url
self.error = message


class Filter(object):
_filter_condition_types = ["rich_text", "number", "checkbox", "select", "multi_select", "date", "phone_number"]

Expand Down Expand Up @@ -261,4 +213,3 @@ def paginate(self, result, method, path, id_, data, after_path):
next_start = r.get("next_cursor")
else:
next_start = None

0 comments on commit f01e7fe

Please sign in to comment.