O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.4. Inner exceptions

C# came out with something called an inner exception – effectively one exception encapsulated within another. [13]

[13] Inner exceptions can be implemented in Java too, but it requires extra manual coding effort. In C#, support for inner exceptions is deeply 'entrenched' high up in the exception hierarchy in System.Exception.

System.Exception's third constructor shown in Table 13.3 enables you to pass in another exception object to the constructor. Think of it as stuffing a smaller envelope with a message into a bigger envelope (which may contain its own message too). To create an new exception object which encapsulates an inner exception object, use the third constructor in Table 13.3.

Inner exceptions are useful when you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required