Skip to content

Commit

Permalink
Merge pull request #278 from EasyPost/bad_request_error
Browse files Browse the repository at this point in the history
feat: maps 400 status codes to BadRequestError class
  • Loading branch information
Justintime50 authored Jul 21, 2023
2 parents c724afc + 8b61781 commit abb6763
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 67 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next release

- Adds new `RequestHook` and `ResponseHook` classes. (un)subscribe to them with the new `subscribeToRequestHook`, `subscribeToResponseHook`, `unsubscribeFromRequestHook`, or `unsubscribeFromResponseHook` methods of an `EasyPostClient`
- Maps 400 status codes to the new `BadRequestError` class

## v6.7.0 (2023-06-06)

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/easypost/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract static class ErrorMessages {
public abstract static class ErrorCodes {
public static final int REDIRECT_CODE_BEGIN = 300;
public static final int REDIRECT_CODE_END = 308;
public static final int BAD_REQUEST_ERROR = 400;
public static final int UNAUTHORIZED_ERROR = 401;
public static final int PAYMENT_ERROR = 402;
public static final int FORBIDDEN_ERROR = 403;
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/easypost/exception/API/BadRequestError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.easypost.exception.API;

import java.util.List;

import com.easypost.model.Error;
import com.easypost.exception.APIException;

public class BadRequestError extends APIException {
/**
* BadRequestError constructor.
*
* @param message the exception message
* @param code the exception code
* @param statusCode the exception status code
* @param errors the errors array
*/
public BadRequestError(final String message, final String code, final int statusCode, List<Error> errors) {
super(message, code, statusCode, errors);
}
}
Loading

0 comments on commit abb6763

Please sign in to comment.