private static async Task <IResponseUnit <TResult> > HandleResponseHandler <TRequest, TResult>(IExecutionContextReader context, IResponseHandlerAsync <TRequest, TResult> h, TRequest request, ILogger logger) { #if DEBUG var timer = Timer.Start(logger, h); #endif IResponse <TResult> rsp; if (h.ExecutionHint != ExecutionHintType.Main) { rsp = await h.Handle(context, request); } else { try { rsp = await h.Handle(context, request); } catch (Exception e) { rsp = Response.Failed <TResult>(); logger.LogError(0, e, $"ResponseHandler {h.GetType().FullName} failed with message {e.Message}"); } } #if DEBUG timer.Completed(); #endif return(Convert(rsp, h.ExecutionHint)); }
private static async Task <IResponseUnit <TResult> > HandleResponseHandler <TResult>(IResponseHandlerAsync <TResult> h, IExecutionContextReader context, ILogger logger) { IResponse <TResult> rsp; #if DEBUG var timer = Timer.Start(logger, h); #endif if (h.ExecutionHint == ExecutionHintType.Main) { rsp = await h.Handle(context); } else { try { rsp = await h.Handle(context); } catch (Exception e) { rsp = Response.Failed <TResult>(); logger.LogError(0, e, e.Message); } } #if DEBUG timer.Completed(); #endif return(Convert(rsp, h.ExecutionHint)); }
private async Task <Response <TResult> > ExecuteResponseHandler <TRequest, TResult>(IRequestBusContext context, IResponseHandlerAsync <TRequest, TResult> handler, TRequest request) { if (handler.ExecutionHint == ExecutionHint.Main) { return(await handler.Handle(context, request)); } try { return(await handler.Handle(context, request)); } catch (Exception e) { _logger.LogError(e, $"Handler {handler.GetType().FullName} failed with message {e.Message}"); } return(null); }