c# - Additional try statement in catch statement - code smell? -


Status:

My application needs to be processed on the first step of business rules (initial effort - catch statement) If a certain error occurs when during the process phase If I call the Auxiliary method, then I have to switch to the second process in the catch statement. The backup process uses the same assistive method if the same error occurs during the second process, then I have to stop the whole process and throw exceptions.

Implementation:

I capture in hold before in statement another try-catch statement was to try-catch statement.

  // Start the initial process {// Initial information helpful method string s1 = "value 1" used; // Call Assistant Method HelperMethod (s1); } Catch (exception E1) {// Backup information if the first process supports an exception method in string s2 = "value 2"; // Try the catch statement for the second process {try HelperMethod (s2); } Hold (exception E2) {throw E2; }}  

Is this code odor? If so, what would be better design patterns to avoid this?

edit

I created some confusion and left that when the first process fails and switches to the second process, then it The sender gives different information about the way. I have updated the scenario to reflect the whole process

If HelmMeth requires a second try, So it is not wrong with it, but tries to hold your code too much, and it destroys the stacktrace from E2.

You only need to:

  try {// Call Assistant Method HelperMethod (); } Hold (Exception E1) {// Perhaps log e1, it is lost here HelperMethod (); }  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -