From c46c7f733a6d1e342ec223ba98b444f702e1e1a6 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Sat, 6 Apr 2024 22:32:01 -0400 Subject: [PATCH] Add HTTP status code to error responses --- .../braydon/mc/model/response/ErrorResponse.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/braydon/mc/model/response/ErrorResponse.java b/src/main/java/me/braydon/mc/model/response/ErrorResponse.java index ca26ee7..f22b5e4 100644 --- a/src/main/java/me/braydon/mc/model/response/ErrorResponse.java +++ b/src/main/java/me/braydon/mc/model/response/ErrorResponse.java @@ -10,25 +10,31 @@ import java.util.Date; * * @author Braydon */ -@NoArgsConstructor @Setter @Getter @ToString +@Getter @ToString public final class ErrorResponse { /** * The status code of this error. */ - @NonNull private HttpStatus status; + @NonNull private final HttpStatus status; + + /** + * The HTTP code of this error. + */ + private final int code; /** * The message of this error. */ - @NonNull private String message; + @NonNull private final String message; /** * The timestamp this error occurred. */ - private Date timestamp; + @NonNull private final Date timestamp; public ErrorResponse(@NonNull HttpStatus status, @NonNull String message) { this.status = status; + code = status.value(); this.message = message; timestamp = new Date(); }