use of com.helger.commons.error.SingleError.Builder in project ph-commons by phax.
the class AbstractValidationEventHandler method handleEvent.
public final boolean handleEvent(@Nonnull final ValidationEvent aEvent) {
final IErrorLevel aErrorLevel = getErrorLevel(aEvent.getSeverity());
final Builder aErrBuilder = SingleError.builder().errorLevel(aErrorLevel);
final ValidationEventLocator aLocator = aEvent.getLocator();
aErrBuilder.errorLocation(new SimpleLocation(getLocationResourceID(aLocator), aLocator != null ? aLocator.getLineNumber() : ILocation.ILLEGAL_NUMBER, aLocator != null ? aLocator.getColumnNumber() : ILocation.ILLEGAL_NUMBER)).errorFieldName(getErrorFieldName(aLocator));
// Message may be null in some cases (e.g. when a linked exception is
// present), but is not allowed to be null!
String sMsg = aEvent.getMessage();
if (sMsg == null) {
if (aEvent.getLinkedException() != null) {
sMsg = aEvent.getLinkedException().getMessage();
if (sMsg == null)
sMsg = "Exception";
} else {
// Does this ever happen????
sMsg = "Validation event";
}
}
aErrBuilder.errorText(sMsg).linkedException(aEvent.getLinkedException());
// call our callback
onEvent(aErrBuilder.build());
// Continue processing?
return continueProcessing(aErrorLevel);
}
Aggregations