Erlang / Erlang Advanced Interview questions
Explain the internal working of exception propagation through nested try/catch blocks?
An exception raised anywhere inside a try block unwinds the call stack looking for the
nearest enclosing catch whose pattern matches the exception's class and reason — skipping
over any intervening function calls that don't themselves catch it, exactly like exception handling in most
languages.
flowchart TD
A[inner() raises error:bad_input] --> B{Caught by inner try/catch?}
B -->|No matching clause| C[Propagates up through middle/]
C --> D{Caught by middle's try/catch?}
D -->|No matching clause| E[Propagates up through outer/]
E --> F{Caught by outer's try/catch?}
F -->|Yes| G[Handled here]
If no enclosing try/catch anywhere up the call chain matches, the exception reaches the top of
the process and terminates it, which then behaves exactly like any other crash — propagating as an exit
signal to linked processes. A nested try only intercepts exceptions raised within its own body;
it has no effect on exceptions from calls made before it or after it returns, which is why the innermost
matching handler along the call chain is the one that actually catches it, not necessarily the outermost.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
