JavaIntermediate#exceptions

What is exception chaining (cause)?

Wrapping a lower-level exception inside a higher-level one while preserving the original via the 'cause' constructor argument, so the full stack trace and root cause remain visible for debugging.

Example
try {
  parseFile();
} catch (IOException e) {
  throw new RuntimeException("Failed to process file", e); // e is the cause
}

Related Questions

1
JavaBeginner#exceptions

What is the order of execution for try, catch, and finally?

Open
2
JavaAdvanced#exceptions

What happens if an exception is thrown in a finally block?

Open
3
JavaIntermediate#exceptions

What is multi-catch in Java 7+?

Open