exception-handling

Additional log output on NUnit test fail

我们两清 提交于 2020-01-24 18:06:53
问题 Whenever an NUnit test fails during its execution (i.e. not when using Assert.* ), I want to log additional information (I'm writing web tests and I am especially interested in the web page's current DOM). How to specify a global exception handler in NUnit which is able to log additional information on NoSuchElementException s - test should still fail of course. 回答1: You could write an NUnit event listener addin that logs the information. See http://www.nunit.org/index.php?p=nunitAddins&r=2.6

When is handling a null pointer/reference exception preferred over doing a null check?

心已入冬 提交于 2020-01-24 12:42:45
问题 I have an odd question that I have always thought about, but could never see a practical use for. I'm looking to see if there would be enough justification for this. When is handling a null pointer/reference exception preferred over doing a null check? If at all. This applies to any language that has to deal with null pointers/references which has exception handling features. My usual response to this would be to perform a null check before doing anything with the pointer/reference. If non

When is handling a null pointer/reference exception preferred over doing a null check?

和自甴很熟 提交于 2020-01-24 12:42:26
问题 I have an odd question that I have always thought about, but could never see a practical use for. I'm looking to see if there would be enough justification for this. When is handling a null pointer/reference exception preferred over doing a null check? If at all. This applies to any language that has to deal with null pointers/references which has exception handling features. My usual response to this would be to perform a null check before doing anything with the pointer/reference. If non

When is handling a null pointer/reference exception preferred over doing a null check?

此生再无相见时 提交于 2020-01-24 12:42:14
问题 I have an odd question that I have always thought about, but could never see a practical use for. I'm looking to see if there would be enough justification for this. When is handling a null pointer/reference exception preferred over doing a null check? If at all. This applies to any language that has to deal with null pointers/references which has exception handling features. My usual response to this would be to perform a null check before doing anything with the pointer/reference. If non

Catching unpickleable exceptions and re-raising

前提是你 提交于 2020-01-24 09:44:25
问题 This is a followup to my question Hang in Python script using SQLAlchemy and multiprocessing. As discussed in that question, pickling exceptions is problematic in Python. This is usually not a issue, but one case when it is, is when errors occur in the python multiprocessing module. Since multiprocessing moves objects around by pickling, if an error occurs inside a multiprocessing process, the entire process may hang, as demonstrated in that question. One possible approach is to fix all the

Catching unpickleable exceptions and re-raising

╄→гoц情女王★ 提交于 2020-01-24 09:44:25
问题 This is a followup to my question Hang in Python script using SQLAlchemy and multiprocessing. As discussed in that question, pickling exceptions is problematic in Python. This is usually not a issue, but one case when it is, is when errors occur in the python multiprocessing module. Since multiprocessing moves objects around by pickling, if an error occurs inside a multiprocessing process, the entire process may hang, as demonstrated in that question. One possible approach is to fix all the

Best practice of log custom exceptions in PHP

╄→гoц情女王★ 提交于 2020-01-24 06:42:40
问题 I have a custom exception (which is further extended in may other custom exceptions). My project requires log all the customExceptions (and all of its decendents) that occurs. I have a logger that can log customException (and anything else). One of the way of doing so is explicitly log the exception whenever it is being handled as follows. try{ //some exception occur } catch(customeException $e) { $log->logException($e); $e->showMessage(); // or do anything that we have to do with the error.

JDK 1.7 onwards, throwing an exception object from catch block does not require a throws clause!!! Why is this so? [duplicate]

落爺英雄遲暮 提交于 2020-01-24 04:29:34
问题 This question already has answers here : Rethrowing an Exception: Why does the method compile without a throws clause? (6 answers) Closed 3 years ago . I came across a weird scenario in java today while coding around. I have a try..catch block in my method which does not have any throws clause and I am able to throw the exception object caught in the catch block. It is an object of the Exception class, hence it is not an unchecked exception. Also, It is not printing the stacktrace if

JDK 1.7 onwards, throwing an exception object from catch block does not require a throws clause!!! Why is this so? [duplicate]

放肆的年华 提交于 2020-01-24 04:29:24
问题 This question already has answers here : Rethrowing an Exception: Why does the method compile without a throws clause? (6 answers) Closed 3 years ago . I came across a weird scenario in java today while coding around. I have a try..catch block in my method which does not have any throws clause and I am able to throw the exception object caught in the catch block. It is an object of the Exception class, hence it is not an unchecked exception. Also, It is not printing the stacktrace if

Catching exceptions thrown in the constructor of the target object of a Using block

为君一笑 提交于 2020-01-24 04:17:09
问题 using(SomeClass x = new SomeClass("c:/temp/test.txt")) { ... } Inside the using block, all is fine with treating exceptions as normal. But what if the constructor of SomeClass can throw an exception? 回答1: Yes , this will be a problem when the constructor throws an exception. All you can do is wrap the using block within a try/catch block. Here's why you must do it that way. using blocks are just syntactic sugar and compiler replaces each using block with equivalent try/finall block. The only