diff --git a/pyinaturalist/auth.py b/pyinaturalist/auth.py index 5a43b6b3..a21d980a 100644 --- a/pyinaturalist/auth.py +++ b/pyinaturalist/auth.py @@ -89,7 +89,9 @@ def get_access_token( if all(payload.values()): logger.info('Retrieved credentials from keyring') else: - raise AuthenticationError('Not all authentication parameters were provided') + raise AuthenticationError( + 'Not all authentication parameters were provided', response=response + ) # Get OAuth access token response = session.post(f'{API_V0}/oauth/token', json=payload) diff --git a/pyinaturalist/v0/observations.py b/pyinaturalist/v0/observations.py index c28a5567..14ab22b3 100644 --- a/pyinaturalist/v0/observations.py +++ b/pyinaturalist/v0/observations.py @@ -328,5 +328,5 @@ def delete_observation(observation_id: int, **params): **params, ) if response.status_code == 404: - raise ObservationNotFound + raise ObservationNotFound(response=response) response.raise_for_status() diff --git a/pyinaturalist/v1/controlled_terms.py b/pyinaturalist/v1/controlled_terms.py index 9f0fc81d..779b2967 100644 --- a/pyinaturalist/v1/controlled_terms.py +++ b/pyinaturalist/v1/controlled_terms.py @@ -71,5 +71,5 @@ def get_controlled_terms_for_taxon(taxon_id: int, **params) -> JsonResponse: # This endpoint returns a 422 if the specified taxon does not exist if response.status_code in (404, 422): - raise TaxonNotFound + raise TaxonNotFound(response=response) return response.json() diff --git a/pyinaturalist/v1/observations.py b/pyinaturalist/v1/observations.py index e1961d74..af93c29d 100644 --- a/pyinaturalist/v1/observations.py +++ b/pyinaturalist/v1/observations.py @@ -558,7 +558,7 @@ def delete_observation(observation_id: int, access_token: Optional[str] = None, **params, ) if response.status_code == 404: - raise ObservationNotFound + raise ObservationNotFound(response=response) response.raise_for_status() @@ -592,4 +592,4 @@ def get_observation( response = get_observations(id=observation_id, access_token=access_token, **params) if response['results']: return convert_observation_timestamps(response['results'][0]) - raise ObservationNotFound() + raise ObservationNotFound(response=response)