Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/com/retailsvc/http/BadRequestException.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
public final class BadRequestException extends RuntimeException {

private static final int DEFAULT_STATUS = 400;
private static final int MIN_CLIENT_ERROR_STATUS = 400;
private static final int MAX_CLIENT_ERROR_STATUS = 499;
private static final int DEFAULT_STATUS = MIN_CLIENT_ERROR_STATUS;

private final int status;
private final String pointer;
Expand Down Expand Up @@ -42,10 +44,10 @@ public BadRequestException(int status, String detail, String pointer, String key

public BadRequestException(
int status, String detail, String pointer, String keyword, Throwable cause) {
super(Objects.requireNonNull(detail, "detail must not be null"), cause);
if (status < 400 || status > 499) {
if (status < MIN_CLIENT_ERROR_STATUS || status > MAX_CLIENT_ERROR_STATUS) {
throw new IllegalArgumentException("status must be 4xx, got " + status);
}
super(Objects.requireNonNull(detail, "detail must not be null"), cause);
this.status = status;
this.pointer = pointer;
this.keyword = keyword;
Expand Down
Loading
Loading