Return 'null' or throw exception
来源:互联网 发布:python如何安装pip教程 编辑:程序博客网 时间:2024/06/05 15:12
转自:http://stackoverflow.com/questions/175532/return-null-or-throw-exception
I have a method that is suppose to return an object if it is found.
If it is not found, should I:
a) return nullb) throw an exceptionc) other
if you are always expecting to find a value then throw the exception if it is missing. The exception would mean that there was a problem.
If the value can be missing or present and both are valid for the application logic then return a null.
More important: What do you do other places in the code? Consistency is important.
- Return 'null' or throw exception
- Java method Exception throw with return instance.
- throw Exception
- Which is better, a return code or an exception?
- C++ unexpected throw exception
- throw an exception
- throw new Exception
- throw new Exception
- C++ 异常 exception throw
- 该不该 throw Exception ?
- throw new Exception
- throw new Exception
- throw new Exception
- throw null 的问题
- java_exception catch or throw
- c#中的throw和return
- throw也是一种return啊
- [c++] exception with no throw
- Hello world
- MzTreeView2.0 动态加载树(xml)
- ReportServer 配置
- poj1275 Cashier Employment
- VB.NET Process类
- Return 'null' or throw exception
- ora-00600 internal error code arguments: [kcratrl_lastbwr],[],[],[],[],[],[],[]
- Process.GetCurrentProcess 方法的VB.NET例子
- HTML 5的八大技术特征
- vb怎么切换到某个进程
- XMLDM2011
- 用eclipse 开发 android应用时出现个错误,“your project contains error(s),please fix them before running your application”
- 这里会给你带来惊喜哦!
- VC中为clistctrl右键弹出菜单