什么时候适合使用错误codeS? [英] When is it appropriate to use error codes?

查看:197
本文介绍了什么时候适合使用错误codeS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在支持异常对象(Java和C#)语言,什么时候适合使用错误codeS ?是使用错误codeS的典型企业应用不断合适?

In languages that support exception objects (Java, C#), when is it appropriate to use error codes? Is the use of error codes ever appropriate in typical enterprise applications?

许多知名的软件系统采用错误codeS(以及相应的错误code参考)。一些例子包括操作系统(Windows),数据库(甲骨文,DB2)和中间件产品(的WebLogic中,WebSphere)。不要错误codeS提供什么样的好处?有什么缺点,使用错误codeS?

Many well-known software systems employ error codes (and a corresponding error code reference). Some examples include operating systems (Windows), databases (Oracle, DB2), and middle-ware products (WebLogic, WebSphere). What benefits do error codes provide? What are the disadvantages to using error codes?

推荐答案

程序,应该采用异常而不是错误codeS。然而,异常不能传播超出了计划。你留下了错误信息或错误codeS任何时间误差必须保持程序。

WITHIN a program one should always use exceptions instead of error codes. However, exceptions can't propagate beyond a program. Any time the error must leave the program you are left with error messages or error codes.

有关简单的事情,将永远是人为操作错误信息,而不codeS的罚款。你可以说找不到文件没有给它一个错误code。但是,如果它可能是在另一端的另一台计算机,那么你应该除了给错误codeS。你不想打破其他系统,当你把它改为文件< X>没有找到。

For simple things that will always be human-operated error messages without codes are fine. You can say "File not found" without giving it an error code. However, if it might be another computer on the other end then you should give error codes in addition. You don't want to break the other system when you change it to "File <x> not found".

这篇关于什么时候适合使用错误codeS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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