Exception chaining (original) (raw)

Property Value
dbo:abstract Exception chaining, or exception wrapping, is an object-oriented programming technique of 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 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 particularly enforced by checked exceptions in the Java programming language, and starting with language version 1.4 almost all exceptions support chaining. 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. (en) 异常链是一种面向对象编程技术,指将捕获的异常包装进一个新的异常中并重新抛出的异常处理方式。原异常被保存为新异常的一个属性(比如cause)。这个想法是指一个方法应该抛出定义在相同的抽象层次上的异常,但不会丢弃更低层次的信息。 比如,播放视频文件的方法可能捕获读取文件过程中的异常,将其包装在新抛出的播放视频文件的异常中。用户界面部分不需要知道读取字节块、 eof 调用或其他操作时发生的错误,这是意外的文件结尾、读取错误或者其他的错误:用户界面只需要从 cause 属性中提取出异常信息。用户界面层会有自身一系列的异常。若对 cause 感兴趣,可以在调试期间、或在适当的日志中查看异常的堆栈跟踪信息( stack track )。 Java 中 受控异常(Checked exceptions) 特别强调了抛出正确类型的异常,从 Java 1.4版本开始,几乎所有的异常都支持异常链。 在运行时环境,比如 Java 或 .Net 中,都有工具连接到运行时引擎;每当感兴趣的异常发生,这些工具就记录下内存中的调试信息以及抛出异常的时间(栈和堆上的值)。这些工具提供异常截取(Exception Interception)功能,它们为生产环境、测试环境、开发环境中的Java程序中出现的的异常提供了root-cause信息。 (zh)
dbo:wikiPageExternalLink https://docs.oracle.com/javase/tutorial/essential/exceptions/chained.html https://www.infoworld.com/article/2075601/exceptional-practices--part-2.html
dbo:wikiPageID 2609775 (xsd:integer)
dbo:wikiPageLength 2103 (xsd:nonNegativeInteger)
dbo:wikiPageRevisionID 1023270495 (xsd:integer)
dbo:wikiPageWikiLink dbr:Object-oriented_programming dbr:Exception_handling dbr:Java_(programming_language) dbc:Software_design_patterns dbr:Stack_trace dbr:JavaWorld
dbp:wikiPageUsesTemplate dbt:Cite_web
dct:subject dbc:Software_design_patterns
gold:hypernym dbr:Technique
rdf:type dbo:TopicalConcept yago:WikicatSoftwareDesignPatterns yago:Abstraction100002137 yago:Cognition100023271 yago:Form105930736 yago:PsychologicalFeature100023100 yago:Structure105726345
rdfs:comment 异常链是一种面向对象编程技术,指将捕获的异常包装进一个新的异常中并重新抛出的异常处理方式。原异常被保存为新异常的一个属性(比如cause)。这个想法是指一个方法应该抛出定义在相同的抽象层次上的异常,但不会丢弃更低层次的信息。 比如,播放视频文件的方法可能捕获读取文件过程中的异常,将其包装在新抛出的播放视频文件的异常中。用户界面部分不需要知道读取字节块、 eof 调用或其他操作时发生的错误,这是意外的文件结尾、读取错误或者其他的错误:用户界面只需要从 cause 属性中提取出异常信息。用户界面层会有自身一系列的异常。若对 cause 感兴趣,可以在调试期间、或在适当的日志中查看异常的堆栈跟踪信息( stack track )。 Java 中 受控异常(Checked exceptions) 特别强调了抛出正确类型的异常,从 Java 1.4版本开始,几乎所有的异常都支持异常链。 在运行时环境,比如 Java 或 .Net 中,都有工具连接到运行时引擎;每当感兴趣的异常发生,这些工具就记录下内存中的调试信息以及抛出异常的时间(栈和堆上的值)。这些工具提供异常截取(Exception Interception)功能,它们为生产环境、测试环境、开发环境中的Java程序中出现的的异常提供了root-cause信息。 (zh) Exception chaining, or exception wrapping, is an object-oriented programming technique of 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. (en)
rdfs:label Exception chaining (en) 异常链 (zh)
owl:sameAs freebase:Exception chaining yago-res:Exception chaining wikidata:Exception chaining dbpedia-hu:Exception chaining dbpedia-zh:Exception chaining https://global.dbpedia.org/id/4jM2e
prov:wasDerivedFrom wikipedia-en:Exception_chaining?oldid=1023270495&ns=0
foaf:isPrimaryTopicOf wikipedia-en:Exception_chaining
is dbo:wikiPageDisambiguates of dbr:Chaining_(disambiguation)
is dbo:wikiPageRedirects of dbr:Exception_Chaining dbr:Exception_wrapping
is dbo:wikiPageWikiLink of dbr:Comparison_of_C_Sharp_and_Java dbr:Exception_handling dbr:Java_(software_platform) dbr:Java_version_history dbr:Exception_Chaining dbr:Chaining_(disambiguation) dbr:Exception_wrapping
is foaf:primaryTopic of wikipedia-en:Exception_chaining