public async Task<Exception> HandleException(Exception exception, Guid handlingId) { ExceptionContext context = new ExceptionContext(Guard.ArgumentNotNull(exception, nameof(exception)), Guard.ArgumentNotNullOrEmpty(handlingId, nameof(handlingId))); ExceptionPolicyEntry policyEntry = this.GetPolicyEntry(exception.GetType()); try { await this.PreHandler(context); await policyEntry.ExceptionHandler(context); await this.PostHandler(context); switch (policyEntry.PostHandlingAction) { case PostHandlingAction.ThrowNew: return context.Exception; case PostHandlingAction.ThrowOriginal: return context.OriginalException; default: return null; } } catch (Exception ex) { return new ExceptionHandlingException(Resources.ExceptionHandlingError, ex); } }