Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cycode/cli/exceptions/custom_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def __str__(self) -> str:
return f'HTTP unauthorized error occurred during the request. Message: {self.error_message}'


class HttpRequestTimeoutError(RequestHttpError):
def __init__(self, error_message: str, response: Response) -> None:
super().__init__(408, error_message, response)

def __str__(self) -> str:
return f'HTTP request timeout error occurred during the request. Message: {self.error_message}'


class ZipTooLargeError(CycodeError):
def __init__(self, size_limit: int) -> None:
self.size_limit = size_limit
Expand Down Expand Up @@ -93,6 +101,12 @@ def __str__(self) -> str:
code='timeout_error',
message='The request timed out. Please try again by executing the `cycode scan` command',
),
HttpRequestTimeoutError: CliError(
soft_fail=True,
code='request_timeout_error',
message='The scan upload timed out. This may be due to a slow connection. '
'Please try again by executing the `cycode scan` command',
),
HttpUnauthorizedError: CliError(
soft_fail=True,
code='auth_error',
Expand Down
4 changes: 4 additions & 0 deletions cycode/cyclient/cycode_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_random_exponential

from cycode.cli.exceptions.custom_exceptions import (
HttpRequestTimeoutError,
HttpUnauthorizedError,
RequestConnectionError,
RequestError,
Expand Down Expand Up @@ -185,4 +186,7 @@ def _get_http_exception(e: exceptions.HTTPError) -> RequestError:
if e.response.status_code == 401:
return HttpUnauthorizedError(e.response.text, e.response)

if e.response.status_code == 408:
return HttpRequestTimeoutError(e.response.text, e.response)

return RequestHttpError(e.response.status_code, e.response.text, e.response)
Loading