Total Complexity | 6 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | package unicon.matthews.common; |
||
14 | public class ErrorResponse { |
||
15 | // HTTP Response Status Code |
||
16 | private final HttpStatus status; |
||
17 | |||
18 | // General Error message |
||
19 | private final String message; |
||
20 | |||
21 | // Error code |
||
22 | private final ErrorCode errorCode; |
||
23 | |||
24 | private final Date timestamp; |
||
25 | |||
26 | protected ErrorResponse(final String message, final ErrorCode errorCode, HttpStatus status) { |
||
27 | this.message = message; |
||
28 | this.errorCode = errorCode; |
||
29 | this.status = status; |
||
30 | this.timestamp = new java.util.Date(); |
||
31 | } |
||
32 | |||
33 | public static ErrorResponse of(final String message, final ErrorCode errorCode, HttpStatus status) { |
||
34 | return new ErrorResponse(message, errorCode, status); |
||
35 | } |
||
36 | |||
37 | public Integer getStatus() { |
||
38 | return status.value(); |
||
39 | } |
||
40 | |||
41 | public String getMessage() { |
||
42 | return message; |
||
43 | } |
||
44 | |||
45 | public ErrorCode getErrorCode() { |
||
46 | return errorCode; |
||
47 | } |
||
48 | |||
49 | public Date getTimestamp() { |
||
50 | return timestamp; |
||
51 | } |
||
53 |