Paritosh Piplewar Paritosh Piplewar - 4 months ago 24
Java Question

what is exception propagation?


what is exception propagation ?


I tried in google but not satisfied with result . Please also explain with some example if possible . C++ , php and java language preferable .

Answer

It's explained, surprisingly, in the Java tutorial page about exceptions.

An exception propagates from method to method, up the call stack, until it's caught. So if a() calls b(), which calls c(), which calls d(), and if d() throws an exception, the exception will propagate from d to c to b to a, unless one of these methods catches the exception.