Skip to content

Commit 95b7874

Browse files
authored
Merge pull request #292 from EasyPost/bad_request_error
feat: maps 400 status codes to new BadRequestError class
2 parents 25aaec8 + 2ef3385 commit 95b7874

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Next Release
44

55
- Adds new `RequestHook` and `ResponseHook` events. (un)subscribe to them with the new `subscribe_to_request_hook`, `subscribe_to_response_hook`, `unsubscribe_from_request_hook`, or `unsubscribe_from_response_hook` methods of an `EasyPostClient`
6+
- Maps 400 status codes to new `BadRequestError` class
67

78
## v8.0.0 (2023-06-06)
89

easypost/errors/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# flake8: noqa
22
from easypost.errors.api.api_error import ApiError
3+
from easypost.errors.api.bad_request_error import BadRequestError
34
from easypost.errors.api.encoding_error import EncodingError
45
from easypost.errors.api.external_api_error import ExternalApiError
56
from easypost.errors.api.forbidden_error import ForbiddenError
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from easypost.errors.api.api_error import ApiError
2+
3+
4+
class BadRequestError(ApiError):
5+
pass

easypost/requestor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030
from easypost.easypost_object import EasyPostObject
3131
from easypost.errors import (
32+
BadRequestError,
3233
EasyPostError,
3334
ForbiddenError,
3435
GatewayTimeoutError,
@@ -49,6 +50,7 @@
4950

5051

5152
STATUS_CODE_TO_ERROR_MAPPING: Dict[int, Any] = {
53+
400: BadRequestError,
5254
401: UnauthorizedError,
5355
402: PaymentError,
5456
403: ForbiddenError,

0 commit comments

Comments
 (0)