コード例 #1
0
 @Override
 public boolean handleEvent(ValidationEvent validationEvent) {
   ValidationEventLocator locator = validationEvent.getLocator();
   lineNumber = locator.getLineNumber();
   columnNumber = locator.getColumnNumber();
   message = validationEvent.getMessage();
   return false;
 }
コード例 #2
0
 @Override
 public boolean handleEvent(ValidationEvent ve) {
   if (ve.getSeverity() == ValidationEvent.FATAL_ERROR
       || ve.getSeverity() == ValidationEvent.ERROR) {
     ValidationEventLocator locator = ve.getLocator();
     log.error(
         "{}: {} at line={}, column={}",
         locator.getURL(),
         ve.getMessage(),
         locator.getLineNumber(),
         locator.getColumnNumber());
     foundErrors = true;
   }
   return true;
 }
コード例 #3
0
  public boolean handleEvent(ValidationEvent event) {
    ValidationEventLocator loc = event.getLocator();
    String file = loc.getURL().getFile();
    try {
      file = URLDecoder.decode(file, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    int lastSlash = file.lastIndexOf('/');
    if (lastSlash > 0) file = file.substring(lastSlash + 1);

    String errorMsg = event.getMessage();
    if (errorMsg == null) {
      Throwable t = event.getLinkedException();
      while (t != null && errorMsg == null) {
        errorMsg = t.getMessage();
        t = t.getCause();
      }
    }

    JOptionPane.showMessageDialog(
        null,
        "<html><h3>Failed to load a custom map</h3><p><i>"
            + errorMsg
            + "</i></p><br><p>file: \"<b>"
            + file
            + "</b>\"<br>line/column: <i>"
            + loc.getLineNumber()
            + "/"
            + loc.getColumnNumber()
            + "</i></p>",
        "Error: custom map loading failed",
        JOptionPane.ERROR_MESSAGE);
    log.error(event.toString());
    return false;
  }