diff --git a/scrython/foundation.py b/scrython/foundation.py index 9b984a6..f72dc73 100644 --- a/scrython/foundation.py +++ b/scrython/foundation.py @@ -2,6 +2,12 @@ import aiohttp import asyncio import urllib +class ScryfallError(Exception): + def __init__(self, error_obj, *args, **kwargs): + super(self.__class__, self).__init__(*args, **kwargs) + self.error_details = **error_obj + + class FoundationObject(object): def __init__(self, _url, override=False, **kwargs): @@ -28,7 +34,7 @@ class FoundationObject(object): loop.run_until_complete(main(loop)) if self.scryfallJson['object'] == 'error': - raise Exception(self.scryfallJson['details']) + raise ScryfallError(self.scryfallJson, message=self.scryfallJson['details']) def _checkForKey(self, key): """Checks for a key in the scryfallJson object. @@ -58,4 +64,4 @@ class FoundationObject(object): KeyError: If key is not found. """ if not key in self.scryfallJson[parent][num]: - raise KeyError('This tuple has no key \'{}\''.format(key)) \ No newline at end of file + raise KeyError('This tuple has no key \'{}\''.format(key))