C # exception handler

I studied how I can change the execution behavior of a C # method, especially when an exception is thrown for support:

Repeat / continue: to repeat the same expression again and continue with Skip / Resume: move to the next statement and continue with execution

I read a lot of answers that this is bad coding practice, but this is for a code converter that converts millions of lines of code from a language that supports this functionality. I need this to be functionally consistent.

0
c # error-handling code-conversion
source share
1 answer

Your only option is to adopt a (frankly awful) style as follows:

var done = false; while (!done) { try { line1(); done = true; } catch {} } done = false; while (!done) { try { line2(); done = true; } catch {} } // etc 

Mixed with:

 try { line1(); } catch {} try { line2(); } catch {} // etc 

Be sure that millions of such lines will make it very difficult and annoying to maintain for the rest of your life.

+1
source share

All Articles