예제 #1
0
        private static Task HandleExceptionAsync(HttpContext context, Exception exception)
        {
            var code = HttpStatusCode.InternalServerError; // 500 if unexpected

            string message = string.Empty;

            message = exception.Message;

            var result = JsonConvert.SerializeObject(ResponseBase.CreateError(message));

            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)code;
            return(context.Response.WriteAsync(result));
        }