Created
January 6, 2016 01:07
-
-
Save The-Quill/9b1397d5a8f351170818 to your computer and use it in GitHub Desktop.
Error handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Foo | |
{ | |
public class Utils | |
{ | |
public static object InvokeAndCatchError(Delegate del, object parameters, params object[] optionalParameters) | |
{ | |
try | |
{ | |
return del.Method.Invoke(parameters, optionalParameters); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Exception occured:"); | |
Console.WriteLine(e); | |
return null; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment