Content deleted Content added
Sample was bad: increased coupling beteween abstraction layers. This coupling should be broken.<br/>Example italized |
m link stack trace using Find link |
||
(13 intermediate revisions by 11 users not shown) | |||
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.
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.▼
In runtime engine environments such as Java or .Net there exist tools that attach to the runtime engine and everytime that an exception of interest occurs they record debugging information that existed in memory at the time the exception was thrown (stack and heap values). These tools are called Exception Interception or Error Interception tools and they provide 'root-cause' information for exceptions in Java programs that run in production, testing or development environments.▼
▲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 almost all exceptions support chaining.
▲In runtime engine environments such as Java or .
== References ==
* {{cite web |last1=Goetz |first1=Brian |date=2001-09-14 |df=mdy |url=https://www.infoworld.com/article/2075601/exceptional-practices--part-2.html |title=Exceptional practices, Part 2 |work=[[JavaWorld]] |accessdate=2020-07-19}}
* [https://docs.oracle.com/javase/tutorial/essential/exceptions/chained.html ''Chained exceptions''] - Sun's Java tutorial
[[Category:Software design patterns]]
|