Ejemplo n.º 1
0
        private async Task HandleUnkownExceptionAsync(HttpContext httpContext, Exception exception)
        {
            _logger.LogError(exception, "Unhandled exception occurred in request {TraceIdentifier}",
                             httpContext.TraceIdentifier);

            httpContext.Response.ContentType = "application/json";
            httpContext.Response.StatusCode  = 500;
            await httpContext.Response.WriteAsync(JsonConvert.SerializeObject(ApiResultViewModel <object> .FromError(
                                                                                  new InternalErrorViewModel(exception.ToString())), _jsonSerializerSettings));
        }
Ejemplo n.º 2
0
 private Task HandleExceptionAsync(HttpContext context, ApiException exception)
 {
     context.Response.ContentType = "application/json";
     context.Response.StatusCode  = exception.StatusCode;
     return(context.Response.WriteAsync(JsonConvert.SerializeObject(ApiResultViewModel <object> .FromError(
                                                                        new ErrorViewModel
     {
         ErrorCode = exception.ErrorCode, ErrorDescription = exception.ErrorDescription
     }),
                                                                    _jsonSerializerSettings)));
 }
Ejemplo n.º 3
0
 public ErrorResult(int statusCode, ErrorViewModel errorViewModel) : base(
         ApiResultViewModel <object> .FromError(errorViewModel))
 {
     StatusCode = statusCode;
 }