Skip to content

Commit

Permalink
Merge pull request #131 from intezer/feat/add-skipped-error
Browse files Browse the repository at this point in the history
feature(errors) - add AnalysisSkippedByRuleError TKT-2287
  • Loading branch information
almogch authored Jan 17, 2024
2 parents 94ac54a + 1c63b07 commit 60b36b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.19.12
_______
- Raise AnalysisSkippedByRuleError when analysis is skipped by rule on server

1.19.11
_______
- Add AnalysisSkippedByRuleError
Expand Down
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.19.11'
__version__ = '1.19.12'
8 changes: 8 additions & 0 deletions intezer_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def raise_for_status(response: requests.Response,
elif 400 <= response.status_code < 500:
if response.status_code == HTTPStatus.UNAUTHORIZED:
raise errors.InvalidApiKeyError(response)
elif response.status_code == HTTPStatus.CONFLICT:
is_skipped_by_rule = response.json().get('result', {}).get('is_skipped_by_rule')
if is_skipped_by_rule:
raise errors.AnalysisSkippedByRuleError(response)
elif response.status_code == HTTPStatus.FORBIDDEN:
try:
error_message = response.json()['error']
Expand Down Expand Up @@ -671,6 +675,10 @@ def _assert_analysis_response_status_code(response: Response):
if response.status_code == HTTPStatus.NOT_FOUND:
raise errors.HashDoesNotExistError(response)
elif response.status_code == HTTPStatus.CONFLICT:
is_skipped_by_rule = response.json().get('result', {}).get('is_skipped_by_rule')
if is_skipped_by_rule:
raise errors.AnalysisSkippedByRuleError(response)

running_analysis_id = response.json().get('result', {}).get('analysis_id')
raise errors.AnalysisIsAlreadyRunningError(response, running_analysis_id)
elif response.status_code == HTTPStatus.FORBIDDEN:
Expand Down

0 comments on commit 60b36b0

Please sign in to comment.