设计模式:异常/错误处理 [英] Design patterns: exception / error handling

查看:140
本文介绍了设计模式:异常/错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有描述异常处理/错误处理设计模式的资源(网络或书籍)?



有很多关于如何编写干净代码的文献,有很多书籍涵盖了设计模式。然而,我从来没有看到任何设计模式,涵盖了哪里和如何最好地处理错误,以及如何最好地传播出现在低级别功能中的错误,提升抽象层次。

解决方案

这些模式和最佳做法经常被绑定到一个特定的平台/语言,所以他们是第一个寻找他们的地方。





作为一个例子,检查以下Java的链接:





通过这些材料可以提供一般的想法来遵循异常处理机制。



还要检查其他SO问题:




Is there any resource (web or book) describing exception handling / error handling design patterns?

There is a lot of literature on how to write clean code, and there are a lot of books covering design patterns. I have, however, never seen any design pattern covering the issue of where and how best to handle errors and how best to propagate an error appearing in a low-level function up the levels of abstraction.

解决方案

These patterns and best practices are often bound to a specific platform/language, so they are the first place to look for them.

As an example check the following links for java:

Going through such materials would give you a general idea to follow in exception handling mechanisms.

Also check other SO questions:

这篇关于设计模式:异常/错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆