Skip to content

Instantly share code, notes, and snippets.

@geraldoyudo
Created September 10, 2018 19:31
Embed
What would you like to do?
java-tutorials/api-error-handling/api-error-object
@Data
@Builder
public class ApiError {
private LocalDateTime timestamp;
private String error;
private int errorCode;
@Singular
private List<ErrorCause> causes;
private ApiError(LocalDateTime timestamp, String error, int errorCode, List<ErrorCause> causes) {
this.timestamp = timestamp == null? LocalDateTime.now(): timestamp ;
this.error = error == null? "": error;
this.errorCode = errorCode;
this.causes = causes == null? Collections.emptyList(): causes;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment