forked from Wavyzz/py-healthchecks.io
linting
This commit is contained in:
@@ -12,10 +12,14 @@ from urllib.parse import urljoin
|
||||
from urllib.parse import urlparse
|
||||
from weakref import finalize
|
||||
|
||||
from httpx import Client, Response
|
||||
from httpx import Client
|
||||
from httpx import Response
|
||||
|
||||
from .exceptions import BadAPIRequestError
|
||||
from .exceptions import CheckNotFoundError
|
||||
from .exceptions import HCAPIAuthError
|
||||
from .exceptions import HCAPIError
|
||||
from healthchecks_io.schemas import checks
|
||||
from .exceptions import HCAPIAuthError, HCAPIError, CheckNotFoundError, BadAPIRequestError
|
||||
|
||||
|
||||
class AbstractClient(ABC):
|
||||
@@ -91,6 +95,7 @@ class AbstractClient(ABC):
|
||||
HCAPIAuthError: Raised when status_code == 401 or 403
|
||||
HCAPIError: Raised when status_code is 5xx
|
||||
CheckNotFoundError: Raised when status_code is 404
|
||||
BadAPIRequestError: Raised when status_code is 400
|
||||
|
||||
Returns:
|
||||
Response: the passed in response object
|
||||
@@ -103,12 +108,14 @@ class AbstractClient(ABC):
|
||||
f"Error when reaching out to HC API at {response.request.url}. "
|
||||
f"Status Code {response.status_code}. Response {response.text}"
|
||||
)
|
||||
|
||||
|
||||
if response.status_code == 404:
|
||||
raise CheckNotFoundError(f"CHeck not found at {response.request.url}")
|
||||
|
||||
|
||||
if response.status_code == 400:
|
||||
raise BadAPIRequestError(f"Bad request when requesting {response.request.url}. {response.text}")
|
||||
raise BadAPIRequestError(
|
||||
f"Bad request when requesting {response.request.url}. {response.text}"
|
||||
)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
Reference in New Issue
Block a user