From a34d6fb6b0897fe4bb52f4756dfb1887aae9ce72 Mon Sep 17 00:00:00 2001 From: Jonathan Abrahamy Date: Mon, 23 Oct 2023 09:40:52 +0200 Subject: [PATCH] feat(url analysis): Add invalid url error TKT-1270 --- intezer_sdk/__init__.py | 2 +- intezer_sdk/_api.py | 3 +++ intezer_sdk/errors.py | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/intezer_sdk/__init__.py b/intezer_sdk/__init__.py index 7816d82..7a1a040 100644 --- a/intezer_sdk/__init__.py +++ b/intezer_sdk/__init__.py @@ -1 +1 @@ -__version__ = '1.19.5' +__version__ = '1.19.6' diff --git a/intezer_sdk/_api.py b/intezer_sdk/_api.py index 31e3fe3..045acec 100644 --- a/intezer_sdk/_api.py +++ b/intezer_sdk/_api.py @@ -745,6 +745,9 @@ def _assert_analysis_response_status_code(response: Response): if result.get('is_url_offline'): raise errors.UrlOfflineError(response) + if error == 'Invalid url': + raise errors.InvalidUrlError(response) + raise errors.ServerError(f'Server returned bad request error: {error}', response) elif response.status_code != HTTPStatus.CREATED: raise errors.ServerError(f'Error in response status code:{response.status_code}', response) diff --git a/intezer_sdk/errors.py b/intezer_sdk/errors.py index 2d5d612..d66ec71 100644 --- a/intezer_sdk/errors.py +++ b/intezer_sdk/errors.py @@ -56,10 +56,12 @@ class HashDoesNotExistError(ServerError): def __init__(self, response: requests.Response): super().__init__('Hash was not found', response) + class FileTooLargeError(ServerError): def __init__(self, response: requests.Response): super().__init__('File is too large', response) + class ReportDoesNotExistError(IntezerError): def __init__(self): super().__init__('Report was not found') @@ -156,10 +158,17 @@ class AlertNotFoundError(AlertError): def __init__(self, alert_id: str): super().__init__(f'The given alert does not exist - {alert_id}') + class InvalidAlertArgumentError(AlertError): def __init__(self, message: str): super().__init__(message) + class UrlOfflineError(ServerError): def __init__(self, response: requests.Response): super().__init__('Url is offline', response) + + +class InvalidUrlError(ServerError): + def __init__(self, response: requests.Response): + super().__init__('Invalid url', response)