public static bool RunAndHandleException(Action <nspec> action, nspec instance, ref Exception targetException) { bool hasThrown = false; Exception exceptionToSet = null; try { action(instance); } catch (TargetInvocationException invocationException) { exceptionToSet = instance.ExceptionToReturn(invocationException.InnerException); hasThrown = true; } catch (Exception exception) { exceptionToSet = instance.ExceptionToReturn(exception); hasThrown = true; } if (targetException == null && exceptionToSet != null) { targetException = exceptionToSet; } return(hasThrown); }
public bool RunAndHandleException(Action <nspec> action, nspec nspec, ref Exception exceptionToSet) { bool hasThrown = false; try { action(nspec); } catch (TargetInvocationException invocationException) { if (exceptionToSet == null) { exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException); } hasThrown = true; } catch (Exception exception) { if (exceptionToSet == null) { exceptionToSet = nspec.ExceptionToReturn(exception); } hasThrown = true; } return(hasThrown); }
public void RunAndHandleException(Action <nspec> action, nspec nspec, ref Exception exceptionToSet) { try { action(nspec); } catch (TargetInvocationException invocationException) { if (exceptionToSet == null) { exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException); } } catch (Exception exception) { if (exceptionToSet == null) { exceptionToSet = nspec.ExceptionToReturn(exception); } } }
public void RunAndHandleException(Action<nspec> action, nspec nspec, ref Exception exceptionToSet) { try { action(nspec); } catch (TargetInvocationException invocationException) { if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException); } catch (Exception exception) { if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(exception); } }
public bool RunAndHandleException(Action<nspec> action, nspec nspec, ref Exception exceptionToSet) { bool hasThrown = false; try { action(nspec); } catch (TargetInvocationException invocationException) { if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(invocationException.InnerException); hasThrown = true; } catch (Exception exception) { if (exceptionToSet == null) exceptionToSet = nspec.ExceptionToReturn(exception); hasThrown = true; } return hasThrown; }