Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.
Open
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
15 changes: 12 additions & 3 deletions src/tastytrade_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ def request(self, method: str, path: str, params: Optional[QueryParams] = tuple(
raise Unauthorized()
if response.status_code >= 500:
raise ServerError()
raise Unknown()

# Try to get error details from response
try:
error_details = response.json()
except JSONDecodeError:
error_details = response.text

raise Unknown(error_details)

def __url(self, path: str, params: Optional[QueryParams] = None) -> str:
url = f'{self.__base_url}{path}'
Expand Down Expand Up @@ -117,5 +124,7 @@ def __init__(self):


class Unknown(TastytradeSdkException):
def __init__(self):
super().__init__('Unknown Error')
def __init__(self, error_details=None):
message = f'Unknown Error: {error_details}' if error_details else 'Unknown Error'
super().__init__(message)
self.error_details = error_details