~/ learn/ comp-308/ cards/ Chaining, rethrow, custom hierarchies & logging
1 of 7

Wrap a low-level cause when re-throwing

Wrap a low-level cause when re-throwing

Answer

try { loadEvents(file); } catch (IOException e) { throw new ControllerException("could not start", e); }

Passing `e` as the cause preserves the original stack trace; `getCause()` retrieves it and the trace shows it under `Caused by:`.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/a21d0550-a6b3-45f5-8557-46cad8ea353d/flashcard utf-8 LF