Exemplo n.º 1
0
        public IActionResult Error(int code)
        {
            var problem = ProblemJson.Create(code);

            // Handle error here
            return(StatusCode(code, problem));
        }
Exemplo n.º 2
0
        private static Task HandleExceptionAsync(HttpContext context, Exception exception)
        {
            var code = HttpStatusCode.InternalServerError;

            var result = JsonConvert.SerializeObject(
                ProblemJson.Create((int)code, exception.Message)
                );

            context.Response.ContentType = ProblemJson.MediaType;
            context.Response.StatusCode  = (int)code;
            return(context.Response.WriteAsync(result));
        }