c# - Best practices for catching and re-throwing .NET exceptions -


what best practices consider when catching exceptions , re-throwing them? want make sure exception object's innerexception , stack trace preserved. there difference between following code blocks in way handle this?

try {     //some code } catch (exception ex) {     throw ex; } 

vs:

try {     //some code } catch {     throw; } 

the way preserve stack trace through use of throw; valid well

try {   // bombs here } catch (exception ex) {     throw; } 

throw ex; throwing exception point, stack trace go issuing throw ex; statement.

mike correct, assuming exception allows pass exception (which recommended).

karl seguin has great write on exception handling in foundations of programming e-book well, great read.

edit: working link foundations of programming pdf. search text "exception".


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -