fengxiang
2018-02-01 cd16757f2cd963749850d6f8897381a8b7a849ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.moral.security.common;
 
import org.springframework.http.HttpStatus;
 
import java.util.Date;
 
/**
 * Error model for interacting with client.
 * 
 * @author vladimir.stankovic
 *
 * Aug 3, 2016
 */
public class ErrorResponse {
    // HTTP Response Status Code
    private final HttpStatus status;
 
    // General Error message
    private final String message;
 
    // Error code
    private final ErrorCode errorCode;
 
    private final Date timestamp;
 
    protected ErrorResponse(final String message, final ErrorCode errorCode, HttpStatus status) {
        this.message = message;
        this.errorCode = errorCode;
        this.status = status;
        this.timestamp = new Date();
    }
 
    public static ErrorResponse of(final String message, final ErrorCode errorCode, HttpStatus status) {
        return new ErrorResponse(message, errorCode, status);
    }
 
    public Integer getStatus() {
        return status.value();
    }
 
    public String getMessage() {
        return message;
    }
 
    public ErrorCode getErrorCode() {
        return errorCode;
    }
 
    public Date getTimestamp() {
        return timestamp;
    }
}