Search in sources :

Example 1 with MalformedByteSequenceException

use of org.apache.xerces.impl.io.MalformedByteSequenceException in project dhis2-core by dhis2.

the class DefaultGmlImportService method createNotifierErrorMessage.

private String createNotifierErrorMessage(Throwable throwable) {
    StringBuilder sb = new StringBuilder("GML import failed: ");
    Throwable rootThrowable = ExceptionUtils.getRootCause(throwable);
    if (rootThrowable == null) {
        rootThrowable = throwable;
    }
    if (rootThrowable instanceof SAXParseException) {
        SAXParseException e = (SAXParseException) rootThrowable;
        sb.append(e.getMessage());
        if (e.getLineNumber() >= 0) {
            sb.append(" On line ").append(e.getLineNumber());
            if (e.getColumnNumber() >= 0) {
                sb.append(" column ").append(e.getColumnNumber());
            }
        }
    } else if (rootThrowable instanceof MalformedByteSequenceException) {
        sb.append("Malformed GML file.");
    } else {
        sb.append(rootThrowable.getMessage());
    }
    if (sb.charAt(sb.length() - 1) != '.') {
        sb.append('.');
    }
    return HtmlUtils.htmlEscape(sb.toString());
}
Also used : SAXParseException(org.xml.sax.SAXParseException) MalformedByteSequenceException(org.apache.xerces.impl.io.MalformedByteSequenceException)

Aggregations

MalformedByteSequenceException (org.apache.xerces.impl.io.MalformedByteSequenceException)1 SAXParseException (org.xml.sax.SAXParseException)1