diff --git a/tests/test_api_client.py b/tests/test_api_client.py index c667c2c..9113360 100644 --- a/tests/test_api_client.py +++ b/tests/test_api_client.py @@ -336,7 +336,7 @@ def get_my_endpoint(self, response): def test_class_decorator_parameter_status_handler_throws(mock_requests, example_url): @staticmethod - def throw_custom(error_code): + def throw_custom(error_code, response): raise ValueError(error_code) @api_client(example_url, status_key='custom_error', diff --git a/tiny_api_client/__init__.py b/tiny_api_client/__init__.py index d78996d..22d1e08 100644 --- a/tiny_api_client/__init__.py +++ b/tiny_api_client/__init__.py @@ -51,7 +51,7 @@ P = ParamSpec('P') T = TypeVar('T') -APIStatusHandler = Callable[[Any], None] | None +APIStatusHandler = Callable[[Any, Any], None] | None APIClient = TypeVar('APIClient', bound=type[Any]) @@ -174,7 +174,7 @@ def _handle_response(response: Any, _logger.warning(f"Code {status_code} from {response.url}") if status_handler is not None: - status_handler(status_code) + status_handler(status_code, endpoint_response) else: raise APIStatusError('Server responded with an error code')