Skip to content

Instantly share code, notes, and snippets.

@Opalo
Last active November 27, 2018 16:30
Show Gist options
  • Save Opalo/688fe7f715868b100b676d1c140c4ae9 to your computer and use it in GitHub Desktop.
Save Opalo/688fe7f715868b100b676d1c140c4ae9 to your computer and use it in GitHub Desktop.
abstract class DomainExceptionWithErrors extends DomainException implements HasDomainErrors {
@Getter
private final MapBindingResult bindingResult;
DomainExceptionWithErrors(HttpStatus status, String reason) {
this(status, reason, null, null);
}
DomainExceptionWithErrors(HttpStatus status, String reason, String objectName) {
this(status, reason, objectName, null);
}
DomainExceptionWithErrors(HttpStatus status, String reason, String objectName,
Seq<DomainError> errors) {
super(status, reason);
this.bindingResult = new MapBindingResult(new HashMap<>(), objectName);
Option.of(errors).forEach(value -> value.forEach(this::addDomainError));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment