Пример #1
0
 protected async Task HandleException(IRequest httpReq, IResponse httpRes, string operationName, Exception ex)
 {
     try
     {
         await HostContext.RaiseAndHandleException(httpReq, httpRes, operationName, ex);
     }
     catch (Exception writeErrorEx)
     {
         //Exception in writing to response should not hide the original exception
         Log.Info("Failed to write error to response: {0}", writeErrorEx);
         //rethrow the original exception
         throw ex;
     }
     finally
     {
         await httpRes.EndRequestAsync(skipHeaders : true);
     }
 }
Пример #2
0
        protected async Task HandleException(IRequest httpReq, IResponse httpRes, string operationName, Exception ex)
        {
            var errorMessage = $"Error occured while Processing Request: {ex.Message}";

            HostContext.AppHost.OnLogError(typeof(HttpAsyncTaskHandler), errorMessage, ex);

            try
            {
                await HostContext.RaiseAndHandleException(httpReq, httpRes, operationName, ex);
            }
            catch (Exception writeErrorEx)
            {
                //Exception in writing to response should not hide the original exception
                Log.Info("Failed to write error to response: {0}", writeErrorEx);
                //rethrow the original exception
                throw ex;
            }
            finally
            {
                httpRes.EndRequest(skipHeaders: true);
            }
        }