forked from p15670423/monkey
Agent: Simplify error handling in HTTPIslandAPIClient
This commit is contained in:
parent
1c6ca24a47
commit
417d167026
|
@ -35,14 +35,8 @@ def handle_island_errors(fn):
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return fn(*args, **kwargs)
|
return fn(*args, **kwargs)
|
||||||
except (
|
except IslandAPIError as err:
|
||||||
IslandAPIConnectionError,
|
raise err
|
||||||
IslandAPIError,
|
|
||||||
IslandAPIRequestError,
|
|
||||||
IslandAPIRequestFailedError,
|
|
||||||
IslandAPITimeoutError,
|
|
||||||
) as e:
|
|
||||||
raise e
|
|
||||||
except (requests.exceptions.ConnectionError, requests.exceptions.TooManyRedirects) as err:
|
except (requests.exceptions.ConnectionError, requests.exceptions.TooManyRedirects) as err:
|
||||||
raise IslandAPIConnectionError(err)
|
raise IslandAPIConnectionError(err)
|
||||||
except requests.exceptions.HTTPError as err:
|
except requests.exceptions.HTTPError as err:
|
||||||
|
@ -67,8 +61,8 @@ def convert_json_error_to_island_api_error(fn):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
fn(*args, **kwargs)
|
fn(*args, **kwargs)
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as err:
|
||||||
raise IslandAPIRequestFailedError(e)
|
raise IslandAPIRequestFailedError(err)
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue