mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-03 03:36:44 +00:00
Stricter type checking
This commit is contained in:
parent
e545ab4a80
commit
009f063067
@ -81,9 +81,13 @@ def _encode_si(si: bytes) -> str:
|
|||||||
class ClientException(Exception):
|
class ClientException(Exception):
|
||||||
"""An unexpected response code from the server."""
|
"""An unexpected response code from the server."""
|
||||||
|
|
||||||
def __init__(self, code: int, *additional_args):
|
def __init__(
|
||||||
Exception.__init__(self, code, *additional_args)
|
self, code: int, message: Optional[str] = None, body: Optional[bytes] = None
|
||||||
|
):
|
||||||
|
Exception.__init__(self, code, message, body)
|
||||||
self.code = code
|
self.code = code
|
||||||
|
self.message = message
|
||||||
|
self.body = body
|
||||||
|
|
||||||
|
|
||||||
register_exception_extractor(ClientException, lambda e: {"response_code": e.code})
|
register_exception_extractor(ClientException, lambda e: {"response_code": e.code})
|
||||||
@ -305,7 +309,9 @@ class _StorageClientHTTPSPolicy:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
# IOpenSSLClientConnectionCreator
|
# IOpenSSLClientConnectionCreator
|
||||||
def clientConnectionForTLS(self, tlsProtocol: TLSMemoryBIOProtocol) -> SSL.Connection:
|
def clientConnectionForTLS(
|
||||||
|
self, tlsProtocol: TLSMemoryBIOProtocol
|
||||||
|
) -> SSL.Connection:
|
||||||
return SSL.Connection(
|
return SSL.Connection(
|
||||||
_TLSContextFactory(self.expected_spki_hash).getContext(), None
|
_TLSContextFactory(self.expected_spki_hash).getContext(), None
|
||||||
)
|
)
|
||||||
|
@ -1428,7 +1428,7 @@ class _FakeRemoteReference(object):
|
|||||||
result = yield getattr(self.local_object, action)(*args, **kwargs)
|
result = yield getattr(self.local_object, action)(*args, **kwargs)
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
except HTTPClientException as e:
|
except HTTPClientException as e:
|
||||||
raise RemoteException(e.args)
|
raise RemoteException((e.code, e.message, e.body))
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
|
Loading…
Reference in New Issue
Block a user