I have a method doSomething()that has one catch try block in which I call another method.
doSomething()
public void doSomething() { try { doSomethingElse(); } catch { // catch implementation goes here } }
In this other method doSomethingElse(), I have no catch try block. I mean the main try-catch method for handling exceptions. If doSomethingElse()there are exceptions, they will bubble up to the doSomething try-catch block method.
doSomethingElse()
Is there something wrong with this approach?
Thank you for your time.
This is completely legal.
Let the exceptions bubble up to where you can / know what to do with them.
try/catch, .
catch - ( , , , , catch).
.
, . ; catch (Exception) throw. , , , Exception.
catch (Exception)
throw
Exception
. , , doSomethingElse() . , , - . -, . doSomethingElse() , doSomething() , . , , .
, . . AccessViolation FatalExecutionEngineError, , CLR , . , , . , . , .
ok, ; doSomethingElse()
;
Source: https://habr.com/ru/post/1769127/More articles:Преобразование модели linq в общий список - generics.NET platform performance - performanceIs there a way to make downloading Netbeans files not crashing with a single error? - netbeansRuby on Rails: check the number of products the store owns - ruby | fooobar.comCombobox display value in Silverlight - silverlighteclipse text formatting - eclipseJython, Django with Sqlite3 - djangoRemove Hudson Problem - clearcaseEncoding problems \ JS decoding strings ↔ C # - javascriptMySQL warning datetime # 1264 - mysqlAll Articles