Skip to content

Commit 4ff8627

Browse files
committed
Returns structured auth error.
1 parent 28a1b68 commit 4ff8627

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

dropbox/dropbox.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import requests
1818

1919
from . import stone_serializers
20+
from .auth import AuthError_validator
2021
from .base import DropboxBase
2122
from .base_team import DropboxTeamBase
2223
from .exceptions import (
@@ -377,7 +378,9 @@ def request_json_string(self,
377378
assert r.headers.get('content-type') == 'application/json', (
378379
'Expected content-type to be application/json, got %r' %
379380
r.headers.get('content-type'))
380-
raise AuthError(request_id, r.json())
381+
err = stone_serializers.json_compat_obj_decode(
382+
AuthError_validator, r.json()['error'])
383+
raise AuthError(request_id, err)
381384
elif r.status_code == 429:
382385
retry_after = r.headers.get('retry-after')
383386
if retry_after is not None:

dropbox/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ def __init__(self, request_id, *args, **kwargs):
77
super(DropboxException, self).__init__(request_id, *args, **kwargs)
88
self.request_id = request_id
99

10+
def __str__(self):
11+
return repr(self)
12+
1013

1114
class ApiError(DropboxException):
1215
"""Errors produced by the Dropbox API."""

0 commit comments

Comments
 (0)