Skip to content

Instantly share code, notes, and snippets.

@geraldoyudo
Created September 10, 2018 19:31
Show Gist options
  • Save geraldoyudo/70c6942bc9131a1e58bc975d98b8beca to your computer and use it in GitHub Desktop.
Save geraldoyudo/70c6942bc9131a1e58bc975d98b8beca to your computer and use it in GitHub Desktop.
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