Lecture overview -- Keyboard shortcut: 'u'  Previous page: Rethrowing an exception -- Keyboard shortcut: 'p'  Next page: Comparison with exception handling in Java -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 26 : 30
Object-oriented Programming in C#
Exception Handling
Raising an exception in an exception handler

Inside a handler, you can either rethrow an exception or raise/throw a new exception

  • Raising and throwing a new exception

    • Use this approach if you, of some reason, want to hide the original exception

      • Security, simplicity, ...

    • Consider propagation of the inner exception

/user/normark/oop-csharp-1/sources/c-sharp/exception/rethrowing/2/prog.csRaising and throwing a new exception. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/exception/rethrowing/2/outputOutput from the program that raises a new exception.


/user/normark/oop-csharp-1/sources/c-sharp/exception/rethrowing/3/prog.csRaising and throwing a new exception, propagating original inner exception. This program is explained


/user/normark/oop-csharp-1/sources/c-sharp/exception/rethrowing/3/outputOutput from the program that raises a new exception, with inner exception.