This repository has been archived on 2023-02-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Sybren A. Stüvel b64577df2e Run submission in a separate thread, and more explicit state
Also more explicit timeouts and an overall better handling of errors.
2018-08-14 16:36:43 +02:00

24 lines
749 B
Python

import requests
class CommunicationError(requests.exceptions.BaseHTTPError):
"""Raised when we get an invalid status code form the MyData server."""
def __init__(self, message: str, response: requests.Response):
self.message = message
self.status_code = response.status_code
self.body = response.text
if response.headers.get('Content-Type', '') == 'application/json':
self.json = response.json()
else:
self.json = None
def __str__(self):
return f'{self.message}; ' \
f'status_code={self.status_code}; json={self.json}; body={self.body}'
class TokenTimeoutError(Exception):
"""Raised when there was a timeout waiting for a client token."""