MediumπŸ‘€ 3-5 yearsπŸ‘€ 8-15 years 1 min read

What are the exception anti-patterns that cause silent failures in production?

Reviewed by Gurusankar M.

Asked inAmazonDeloitteCognizantAccenture
#exceptions#logging#anti-patterns#observability
Report issue

⚑ Short Answer

Swallowing exceptions (empty catch), catching Exception/Throwable too broadly, losing the cause when re-wrapping, logging-and-rethrowing (double logs), and using exceptions for control flow. Each hides root cause or floods logs.

β˜•Coffee Chat Question

Concept Made Simple

β€œWhat are the exception anti-patterns that cause silent failures in production?”

🧠Mind Map Answer

Remember It Faster

Swallow→catch {} → invisible failure
Too broad→catch (Exception) hides bugs
Lost cause→throw new X() without e
Log+rethrow→duplicate noise

⌨️Hands-on Keyboard

Learn by Doing

java
// BAD
try { pay(); } catch (Exception e) { } // swallowed

// GOOD
try { pay(); }
catch (PaymentException e) {
    throw new OrderFailedException("pay failed for " + id, e); // keep cause
}

πŸ”₯What If?

Think Beyond the Expected

A request fails but the logs show nothing β€” most likely cause?

A swallowed exception (empty catch) or a catch that logs at DEBUG/returns null. The fix: never swallow; log at the right level once, at the boundary, with the full stack trace and a correlation id.

πŸ˜‚Real World

The hardest production incidents to debug are the ones with empty catch blocks β€” the failure happened, but there's no trace, so you're blind. Log-once-at-the-edge with correlation ids is the cure.

🎯Interviewer's Expectation

Keywords they're listening for:

βœ“ never swallowβœ“ catch narrowlyβœ“ preserve causeβœ“ log once at boundaryβœ“ correlation id

⚠️Common Mistakes

  • βœ—Empty catch blocks
  • βœ—throw new RuntimeException(e.getMessage()) β€” drops the stack
  • βœ—Logging and rethrowing the same exception repeatedly

βœ…Best Practices

  • βœ“Log once at the boundary with the full cause + correlation id
  • βœ“Catch the most specific type
  • βœ“Wrap with the cause; fail fast on programming errors

πŸ”Follow-up Questions

  • 1Where should you log vs rethrow in a layered app?
  • 2How do correlation/trace ids help across microservices?
  • 3Why is catching Throwable especially dangerous?

🧩Related Technologies

SLF4J/LogbackMDC correlation id@ControllerAdviceOpenTelemetry

Continue Learning with AI

Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β€” AI is your learning companion, not a shortcut.

Plain-language foundations

I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner.

Topic: Exceptions (Core Java)
Interview question: "What are the exception anti-patterns that cause silent failures in production?"

Please:
1. Explain the core idea in simple, plain language, using an everyday analogy.
2. Define any technical terms you use.
3. Walk through one small, concrete example.
4. Finish with a single sentence I can easily remember.

Keep the tone friendly and assume I'm new to this topic.

Was this answer helpful?

Support our platform by exploring our recommended products.

As an Amazon affiliate, purchases through these links may earn us a small commission β€” at no extra cost to you. It helps keep Full Stack Interview Guru free.

Related Questions