This repository has been archived on 2022-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
pyurbantz/urbantz/exceptions.py

20 lines
489 B
Python
Raw Normal View History

2018-10-20 16:57:02 +00:00
class APIError(Exception):
2018-10-25 17:10:49 +00:00
"""
An error returned by the UrbanTZ API.
This does not include HTTP errors.
"""
2018-10-20 16:57:02 +00:00
def __init__(self, error):
2018-10-25 17:10:49 +00:00
"""
:param error: Parsed JSON error from the API.
:type error: dict
"""
2018-10-20 16:57:02 +00:00
self.message = error.get('message')
self.code = error.get('code')
def __repr__(self):
return "<APIError '{}'>".format(str(self))
def __str__(self):
return self.message or 'Unknown error'