pyEDSM/edsm/exception.py
2021-01-28 17:21:21 +01:00

41 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class ServerError(Exception):
"""
Exception used for everything server-related; basically every time the API
doesnt reply with a `200 OK`, this is whats going to be raised.
"""
def __str__(self):
return "Server Error fetching {}, params: {}.".format(self.args[0],
self.args[1])
pass
class NotFoundError(Exception):
"""
Base class for all exceptions related to not finding an item in EDSMs
database. All specific exceptions handling misses should be derived from this.
Note: this is raised by the base class for all API endpoints. Implementations
derived from it should catch it and raise a more specific one.
"""
class SystemNotFoundError(NotFoundError):
"""
Raised when a system could not be found in the database. Used by the
`systemApi` and `systemsApi` modules.
"""
def __str__(self):
params = self.args[0]
if 'systemName' in params:
return "System {} not found.".format(params['systemName'])
else:
return "Systems {} not found.".format(params['systemName[]'])
class CommanderNotFoundError(NotFoundError):
"""
Raised when a commander could not be found in the database (or has their
profile/logs hidden). Used by the `commanderApi` and `logsApi` modules.
"""
def __str__(self):
params = self.args[0]
return "Commander {} not found or has not made his flight logs public.".format(params['commanderName'])