What is the best way to re-use exception handling logic in C#? -
I have two functions that have enough logic but very exception handling:
public Zero DoIt1 / DoIt2 has different arguments, but the same exception handling {try ... doIt1 logic (MySpecialException myEx) {Debug.WriteLine (myEx.MyErrorString); throw; } Hold (exception e) {Debug.WriteLine (e.ToString ()); throw; }}
It is not possible to use single entry point for DoIt1 and DoIt2, because what is the best way to block exception blocks from them?
It depends ... if there is too much similarity, As a parameter, you can either talk in the form of an interface or representative:
Zero Fu (Action Cheat Toado) {If Tudo == blank) Throw new logic; ("Cheese trudo"); Try {thingToDo (); } Hold {...} // many}
and call as:
FU (representative {/ * logic one * / }); Fu (Rep. {* * Logic B * /});
Comments
Post a Comment