BigW Consortium Gitlab

Commit 3099b2a3 by Tarun Bhardwaj

Add better exceptions

parent fd53093f
......@@ -9,6 +9,8 @@ import tempfile
import time
from _multipartformdataencode import encode_multipart_formdata
from .exceptions import EtsyConcurrencyError, EtsyAPILimitError
missing = object()
......@@ -314,6 +316,10 @@ class API(object):
try:
self.data = self.decode(data)
except json.JSONDecodeError:
if 'being edited by another process' in data:
raise EtsyConcurrencyError(data)
if 'exceeded your quota' in data:
raise EtsyAPILimitError(data)
raise ValueError(
'Could not decode response from Etsy as JSON: %r' % data)
......
class EtsyConcurrencyError(Exception):
pass
class EtsyAPILimitError(Exception):
pass
......@@ -30,6 +30,7 @@ def write_config_file(oauth_token):
config_file.write("oauth_token_key = %r\n" % oauth_token.key)
config_file.write("oauth_token_secret = %r\n" % oauth_token.secret)
try:
import config
except ImportError:
......@@ -94,4 +95,5 @@ def testCreateListing():
print "Result of uploading image: %r" % result
testCreateListing()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment