Skip to content

Error handling

Francesco Palozzi edited this page Jun 5, 2026 · 1 revision

Error Handling

All parsing methods declare IOException and ParseException. The auto-detecting overloads additionally throw IllegalArgumentException when the format cannot be identified.

try {
    String result = unifier.process(inputFile, true);
} catch (IOException e) {
    // File could not be read
    System.err.println("I/O error: " + e.getMessage());
} catch (java.text.ParseException e) {
    // File was readable but content did not match the expected grammar
    System.err.println("Parse error at offset " + e.getErrorOffset() + ": " + e.getMessage());
} catch (IllegalArgumentException e) {
    // Auto-detection failed — the format was not recognised
    System.err.println("Unknown format: " + e.getMessage());
}

Common Causes of ParseException

  • The file is in a valid format for tool A but you passed ToolType.B.
  • The file is truncated or corrupted.
  • The tool version produced output with a minor format variation not covered by the grammar.

Common Causes of IllegalArgumentException (auto-detection)

  • The file is empty or too small (fewer than a few lines).
  • The format is entirely custom or not one of the seven supported tools.

Logging | Next: Running Tests

Clone this wiki locally