From 5b6412f849f37c2e106f2aa291776939cd6cf71a Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Sat, 31 Aug 2019 07:02:58 -0400 Subject: [PATCH] show how to handle errors --- examples/handle_errors.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 examples/handle_errors.py diff --git a/examples/handle_errors.py b/examples/handle_errors.py new file mode 100644 index 0000000..7120d4e --- /dev/null +++ b/examples/handle_errors.py @@ -0,0 +1,8 @@ +import scrython + +# oops, we asked for an exact match to a card, but failed to put the name in quotes +# that's going to throw a Scryfall error +try: + search = scrython.cards.Search(q="!Black Lotus") +except scrython.ScryfallError as e: + print(str(e.status) + ' ' + e.code + ': ' + e.details)