Search in sources :

Example 1 with Builder

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);
}
Also used : Builder(com.helger.commons.error.SingleError.Builder) IErrorLevel(com.helger.commons.error.level.IErrorLevel) ValidationEventLocator(javax.xml.bind.ValidationEventLocator) SimpleLocation(com.helger.commons.location.SimpleLocation)

Aggregations

Builder (com.helger.commons.error.SingleError.Builder)1 IErrorLevel (com.helger.commons.error.level.IErrorLevel)1 SimpleLocation (com.helger.commons.location.SimpleLocation)1 ValidationEventLocator (javax.xml.bind.ValidationEventLocator)1