using System; namespace Quadarax.Foundation.Core.Exceptions { public static class TryCatchExt { public static Exception TryCatch(this object owner, Func fnc) { if (owner == null) throw new ArgumentNullException(nameof(owner)); if (fnc == null) return null; try { fnc(); } catch (Exception e) { return e; } return null; } public static Exception TryCatch(this object owner, Action fnc) { if (owner == null) throw new ArgumentNullException(nameof(owner)); if (fnc == null) return null; try { fnc(); } catch (Exception e) { return e; } return null; } } }