From f01e7fe46171d212ed1b20cb3fd673450b81d96e Mon Sep 17 00:00:00 2001 From: lastorel Date: Tue, 29 Mar 2022 23:07:12 +0300 Subject: [PATCH] #10 old exceptions removed --- pytion/query.py | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/pytion/query.py b/pytion/query.py index 0bcf091..996c26f 100644 --- a/pytion/query.py +++ b/pytion/query.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import json import logging from urllib.parse import urlencode from typing import Dict, Optional, Any, Union @@ -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"] @@ -261,4 +213,3 @@ def paginate(self, result, method, path, id_, data, after_path): next_start = r.get("next_cursor") else: next_start = None -