Skip to content

Exception handling

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

Exception Handling

Exception Reference

Exception Checked? When it is thrown
IOException I/O error while reading or writing files
IllegalArgumentException A file with a different format from the already-loaded ones is loaded
RNAInputFileParserException (unchecked) File content does not conform to the expected syntax, or a weak bond has invalid indices

Robust Handling Pattern

try {
    RNAFile file = io.loadFile(Path.of("structure.bpseq"));
    RNAFile translated = translator.translate(file, RNAFormat.DB);
    io.saveFiles(List.of(translated), Path.of("/output/"), false, false, "");
 
} catch (IOException e) {
    System.err.println("I/O error: " + e.getMessage());
 
} catch (IllegalArgumentException e) {
    System.err.println("Incompatible format: " + e.getMessage());
 
} catch (RNAInputFileParserException e) {
    System.err.println("Parsing error: " + e.getMessage());
}

Common Causes

IllegalArgumentException

Thrown when a file whose format differs from the session's recognized format is loaded. Fix by calling io.clearAllDataStructures() before loading files of a different format.

RNAInputFileParserException

Thrown when:

  • The file content does not match any recognized format grammar.
  • A bond references an index outside the valid range (1 to sequence length). Check the file content and ensure it conforms to one of the supported formats.

IOException

Standard Java I/O exceptions — file not found, permission denied, disk full, etc.


See Also

Clone this wiki locally