c# - When to handle the exception? -


I am writing an app that I can work with several steps. I have some code that is given below and I want to know that it is a normal way of handling exceptions. This code will probably never be seen by someone else, but this can happen, so I would like to know that I'm handling exceptions as anyone would expect.

  IEnumerable & lt; Work & gt; Work; Try for forhave (various tasks in the task) {try to work (loading libraries, connecting, logging arc, etc.) {Boiler Plate Prep). Step (Try {step.Execute ()}} Hold (Exception Pre) {LogStepError (Phase, Ex); Throw;}} // Notify the Part The task is completed successfully, complete the task} Catch (Exception } {LogTaskFailure}} Finally {// close connection, etc}} Interface iTeskest {execute zero} () {}}  

I also wanted to add that the task Steps are implementing the iTscope interface, so implementing execution is not my own (Ach In this example, it is in this example but can apply any interface). My code only increases the library and runs any iTASC and their iStuscst steps.

Go ahead and grab the exception to log your existence, but if you have not really solved this problem which has thrown the exception, please handle the caller Restore it for. Do.

Your code catches a TaskIsBogusException and PrinterOnFireException and treats them the same way: log in and continue with the next work It is okay to do this with a fake task because you are doing anyway with the job, but if you capture PrinterOnFireException and do not install it again, by Golly, the printer still The fire was not better.

If you are not going to restore, then only catch the specific exception types that are meant to handle your code at that time.

Leave everything (either the stuff you do not understand, or the stuff you never imagined).


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -