diff options
author | Colin Watson <cjwatson@debian.org> | 2018-10-15 10:58:26 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2018-10-15 10:58:56 +0100 |
commit | f00e0b7d3ea974ffaa8bc284ad2b7df6fcb77eb2 (patch) | |
tree | 5acfe37d50981ef409c3a0753b8d048eaed53558 /macaroonbakery/httpbakery/_error.py | |
parent | 83e714c5f5f17a4db661ba942f8da617dccac9bb (diff) | |
parent | 619cb9d927e2d6955d0b6a97d4d4c5ea9548150a (diff) |
Update upstream source from tag 'upstream/1.2.1'
Update to upstream version '1.2.1'
with Debian dir ccd0e7fdc6e29a6c6f8c47c3e463ae6e6a3343c3
Diffstat (limited to 'macaroonbakery/httpbakery/_error.py')
-rw-r--r-- | macaroonbakery/httpbakery/_error.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/macaroonbakery/httpbakery/_error.py b/macaroonbakery/httpbakery/_error.py index ff75f13..0ef7e7b 100644 --- a/macaroonbakery/httpbakery/_error.py +++ b/macaroonbakery/httpbakery/_error.py @@ -20,7 +20,7 @@ class DischargeError(Exception): '''This is thrown by Client when a third party has refused a discharge''' def __init__(self, msg): super(DischargeError, self).__init__( - 'third party refused discharge: {}'.format(msg)) + 'third party refused dischargex: {}'.format(msg)) class InteractionError(Exception): @@ -106,11 +106,16 @@ class Error(namedtuple('Error', 'code, message, version, info')): '''Create an error from a JSON-deserialized object @param serialized the object holding the serialized error {dict} ''' - code = serialized.get('Code') - message = serialized.get('Message') - info = ErrorInfo.from_dict(serialized.get('Info')) - return Error(code=code, message=message, info=info, - version=bakery.LATEST_VERSION) + # Some servers return lower case field names for message and code. + # The Go client is tolerant of this, so be similarly tolerant here. + def field(name): + return serialized.get(name) or serialized.get(name.lower()) + return Error( + code=field('Code'), + message=field('Message'), + info=ErrorInfo.from_dict(field('Info')), + version=bakery.LATEST_VERSION, + ) def interaction_method(self, kind, x): ''' Checks whether the error is an InteractionRequired error |