Java Zero to All All questionsPractise free
Interview questions › Java Foundations — Zero to Basics › Exception Handling & Custom Exceptions

What does it mean to 'swallow' an exception, and what are the correct patterns for translation and chaining?

Level II · JuniorException Handling & Custom Exceptions
Short answer

Swallowing means catching an exception and doing nothing (or just logging and continuing) so the failure is silently lost — a leading cause of undebuggable production issues.

Explanation

The right patterns are: handle it meaningfully, rethrow, or translate it to a higher-level exception while preserving the cause via the chaining constructor (new ServiceException("...", cause)) so the stack trace survives. Never catch Throwable/Exception broadly to hide problems, and never catch and lose the cause.

Common mistakes
  • Logging and rethrowing at every layer, producing duplicate stack traces.
  • Throwing a new exception without passing the original as the cause.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for Exception Handling & Custom Exceptions.

Practise free

More on Exception Handling & Custom Exceptions