Content deleted Content added
No edit summary |
Sample was bad: increased coupling beteween abstraction layers. This coupling should be broken.<br/>Example italized |
||
Line 1:
'''Exception chaining''', or '''exception wrapping''', is an [[object-oriented programming]] technique of [[exception handling|handling exceptions]] by re-throwing a caught exception after wrapping it inside a new exception. The original exception is saved as a property (such as ''cause'') of the new exception. The idea is that a method should throw exceptions defined at the same abstraction level as the method itself, but without discarding information from the lower levels.
''For example, a method to play a movie file might handle exceptions in reading the file by re-throwing them inside an exception of movie playing. The user interface
Throwing the right kind of exceptions is particularly enforced by [[exception handling#Checked exceptions|checked exceptions]] in the [[Java (programming language)|Java programming language]], and starting with language version 1.4 all exceptions support chaining.
|