Throwing an exception not only unwinds the test but also signals an error.
抛出异常不仅要展开测试,还将报告错误。
If the caller won't be able to handle the exception in a meaningful way, consider throwing an unchecked (run-time) exception.
如果调用者不能以有意义的方式处理这个异常,那么考虑抛出一个未检查的(运行时)异常。
This means that if you do your validation while processing the parameters, you can - by throwing an exception - prevent your class from being finalized.
这意味着,如果在处理参数时执行验证,可以通过抛出异常预防类被终结。
Of course, just throwing out an exception isn't a very robust way to deal with problems.
当然,仅仅抛出异常并不一定是解决问题的最佳方式。
This is thrown when the run method is allocated a thread, but either the setup of context failed or the method exited by throwing a runtime exception.
这个异常是在将run方法分配给一个线程时抛出的,但这个异常或者是上下文设置失败,或者是通过抛出运行时异常退出方法。
Instead of throwing an unchecked exception with a call to the add method, you just get false returned by offer .
它不是对调用add方法抛出一个unchecked异常,而只是得到由offer返回的false。
Throwing an exception would not help in our case because we would then have to add instanceof checks in hasConsecutiveZeros to ensure that we didn't trigger the exception.
抛出一个异常在本例中帮不了什么忙,因为我们将不得不在hasConsecutiveZeros中添加instanceof 检查语句以确保我们没有触发异常。
" Writing good exceptions" (developerWorks, May 2003) offers some practical advice on throwing and catching exceptions and refining your exception-handling sensibilities.
“编写出色的异常 ”(developerWorks, 2003 年5 月)提供了一些关于抛出和捕获异常以及改善异常处理灵敏度的一些实际建议。
Instead of throwing an exception when the queue is empty, the reader thread now blocks itself on the condition variable.
当队列是空的时候,读线程现在并不抛出异常,而是在条件变量上阻塞自身。
The first mistake that nonnative speakers make is to return a value indicating an error, instead of throwing an exception.
非原生语言使用者的第一类错误是返回一个表示错误的值,而不是抛出异常。
If timeouts are not expected, then throwing an exception might be a better choice.
如果预料不会超时,则引发异常可能是一种更好的选择。
The original JAXB code unconditionally verified the structure of documents, throwing an exception and aborting the processing if an error was found.
原来的JAXB代码无条件地验证文档的结构,如果发现错误,则抛出异常并中止处理。
Another way that listeners can make trouble for unwary event sources is throwing an unchecked exception.
对于不小心的事件源,侦听器会造成麻烦的另一个方式是:抛出未检测的异常。
Your handler code can make use of the information passed by the call-backs, but cannot affect the parsing (except by throwing an exception).
处理程序代码可以使用这些回调中传递的信息,但是不能影响解析过程(除了引发一个异常)。
Select "title" in the table, and in the property grid change "NullValue" to "(empty)" - that is, treat the title as the empty string whenever no data exists for it, instead of throwing an exception.
在Datatable中选中“title”,在属性栏里将“NullValue”的值更改为“(Empty)”-这样做是为了在没有与“title”对应的数据时,把title做为一个空字符串来对待,以此替换抛出异常。
While remove behaves like the collection interface version, instead of throwing an exception when called with an empty collection, the new poll method just returns null.
remove的行为与Collection接口的版本相似,但是新的poll方法在用空集合调用时不是抛出异常,只是返回null。
JSR 310 fixes this by throwing an exception for null arguments.
JSR 310通过抛出null参数异常修复了这个问题。
For instance, adding elements to a Queue could be done with the add method of Collection, throwing an unchecked exception on failure.
例如,向Queue添加元素可以用Collection的add方法来实现,它在失败时会抛出未检测异常。
The schema validator can now take responsibility for throwing an exception for the bug mentioned earlier.
现在,模式验证器可以负责为前面那个bug抛出异常。
Add records adds records without throwing an exception.
AddRecords添加记录,没有抛出异常。
If any of the arguments are Infinity the transformation matrix must be marked as infinite instead of the method throwing an exception.
如果任意一个参数是无限大,变形矩阵也必须被标记为无限大,否则会抛出异常。
An exception is raised by throwing an object.
异常是通过抛出对象而引发的。
Throwing an exception will cause the error event to be invoked, and the connection will be closed.
抛出一个异常将导致错误事件被调用,并且连接会被关闭。
If any of the above steps fails with an exception that the service constructor may throw (according to its exception specification), the service constructor also fails by throwing that exception.
如果以上任何步骤因服务构造函数可能抛出(根据其异常规范)的异常而失败,则服务构造函数也会抛出该异常并以失败告终。
All threads that are not daemon threads have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.
非守护线程的所有线程都已停止运行,无论是通过从对run方法的调用中返回,还是通过抛出一个传播到run方法之外的异常。
The following example fixes the previous violation by checking the error code and throwing an exception when the call fails.
下面的示例通过在调用失败时检查错误代码并引发异常修复了前面的冲突。
You can use the second parameter to control throwing an exception on unmappable characters.
可以使用第二个参数控制在遇到无法映射的字符时是否引发异常。
This combination of parameter Settings turns best-fit mapping off, but enables the exception-throwing mechanism as a safety precaution.
这种参数设置组合可以关闭最佳映射,但启用异常引发机制作为安全预防措施。
Note that many other input operations return a special value on end of stream rather than throwing an exception.
注意很多其它的输入操作会在流的末尾返回一个特定值而不是抛出异常。
This method avoids throwing an exception if the entry is not currently in the dictionary.
如果字典中当前没有该项,则此方法可避免引发异常。
应用推荐