Skip to content

Commit

Permalink
change errors' messages to official
Browse files Browse the repository at this point in the history
  • Loading branch information
wchistow committed Sep 6, 2023
1 parent ccf3f0f commit 791ad1c
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/pystackapi/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,35 @@ def __init__(self, code: int, url: str) -> None:
self.msg = ''
match code:
case 400:
self.msg = f'Bad request for url {url}'
self.msg = 'An malformed parameter was passed'
case 401:
self.msg = 'Acess token required'
self.msg = 'No access_token was passed'
case 402:
self.msg = 'Invalid acess token'
self.msg = ('An access_token that is malformed, expired,'
' or otherwise incorrect was passed')
case 403:
self.msg = 'Acess denied'
self.msg = 'The access_token passed does not have sufficient permissions'
case 404:
self.msg = f'Url {url} not found'
self.msg = 'No matching method was found'
case 405:
self.msg = 'Key required'
self.msg = 'No key was passed'
case 406:
self.msg = 'Access token compromised'
self.msg = 'Access token may have been leaked, it will be invalidated'
case 407:
self.msg = 'Write failed'
self.msg = 'A write operation was rejected'
case 409:
self.msg = 'Duplicate request'
self.msg = 'A request identified by the given request_id has already been run'
case 500:
self.msg = 'Internal error'
self.msg = ('An error was encountered while servicing this request,'
' it has been recorded')
case 502:
self.msg = 'Throttle violation'
self.msg = ('Some violation of the throttling or request quota contract'
' was encountered')
case 503:
self.msg = 'Temporarily unavailable'
self.msg = 'he method, or the entire API, is temporarily unavailable'

if self.msg:
self.msg += f' (status code {code}).'
self.msg = f'"{self.msg}" on URL {url} (status code {code}).'
else:
self.msg = str(code)

Expand Down

0 comments on commit 791ad1c

Please sign in to comment.