Knowledge (XXG)

Exception chaining

Source 📝

65:
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
38:
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
35:) 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. 66:
Exception Interception and they provide "root-cause" information for exceptions in Java programs that run in production, testing, or development environments.
114: 31:
by re-throwing a caught exception after wrapping it inside a new exception. The original exception is saved as a property (such as
59: 24: 77: 96: 55: 28: 43:. The user interface layer will have its own set of exceptions. The one interested in 108: 62:, and starting with language version 1.4 almost all exceptions support chaining. 48: 82: 54:
Throwing the right kind of exceptions is particularly enforced by
8: 7: 76:Goetz, Brian (September 14, 2001). 51:during debugging or in proper log. 14: 78:"Exceptional practices, Part 2" 1: 25:object-oriented programming 131: 60:Java programming language 115:Software design patterns 101:- Sun's Java tutorial 29:handling exceptions 98:Chained exceptions 56:checked exceptions 21:exception wrapping 17:Exception chaining 122: 93: 91: 90: 130: 129: 125: 124: 123: 121: 120: 119: 105: 104: 88: 86: 75: 72: 39:extracted from 12: 11: 5: 128: 126: 118: 117: 107: 106: 103: 102: 94: 71: 68: 13: 10: 9: 6: 4: 3: 2: 127: 116: 113: 112: 110: 100: 99: 95: 85: 84: 79: 74: 73: 69: 67: 63: 61: 57: 52: 50: 46: 42: 36: 34: 30: 27:technique of 26: 22: 18: 97: 87:. Retrieved 81: 64: 53: 47:can see its 44: 40: 37: 32: 20: 16: 15: 49:stack trace 89:2020-07-19 70:References 83:JavaWorld 109:Category 23:, is an 58:in the 45:cause 41:cause 33:cause 19:, or 111:: 80:. 92:.

Index

object-oriented programming
handling exceptions
stack trace
checked exceptions
Java programming language
"Exceptional practices, Part 2"
JavaWorld
Chained exceptions
Category
Software design patterns

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.