Content deleted Content added
copy edit and clarify |
m link stack trace using Find link |
||
(20 intermediate revisions by 18 users not shown) | |||
Line 1:
'''Exception chaining''', or '''exception wrapping''', is an [[object-oriented programming]] technique of
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 doesn't need to know whether the error occurred during reading chunk of bytes or calling eof(). It needs only the exception message extracted from ''cause''. The user interface layer will have its own set of exceptions. The one interested in ''cause'' can see its [[stack trace]] during debugging or in proper log.
Throwing the right kind of exceptions is particularily enforced by [[exception handling#Checked exceptions|checked exceptions]] in the [[Java programming language]], and starting with language version 1.4 all exceptions support chaining.▼
▲Throwing the right kind of exceptions is
In runtime engine environments such as Java or .NET there exist tools that attach to the runtime engine and every time 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 and they provide "root-cause" information for exceptions in Java programs that run in production, testing, or development environments.
== 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]]
|