/// <summary> /// Process method executes after the Handle method on your handler. /// </summary> /// <param name="request">Request instance.</param> /// <param name="response">Response instance.</param> /// <param name="cancellationToken">Cancellation token.</param> /// <returns> /// An awaitable task. /// </returns> public Task Process(TRequest request, TResponse response, CancellationToken cancellationToken) { var behaviorName = typeof(ResponseBehavior <TRequest, TResponse>).Name; var requestName = typeof(TRequest).Name; this._logger .ForContext("Behavior", behaviorName) .ForContext("IsSuccessful", response.IsSuccessful) .ForContext("RequestName", requestName) .ForContext("RequestPayload", request, true) .ForContext("ResponsePayload", response, true) .Information("Processed request."); if (response.IsSuccessful) { return(Task.CompletedTask); } var requestException = new AppException(); foreach (var item in response.Exceptions) { requestException.AddRange(item.Key, item.Value); } throw requestException; }