Beispiel #1
0
        private HttpExceptionResponseInfo GetValue(Type type)
        {
            if (!_exceptionInfo.TryGetValue(type, out HttpExceptionResponseInfo info))
            {
                info = new HttpExceptionResponseInfo(HttpStatusCode.InternalServerError, null);
            }

            return(info);
        }
Beispiel #2
0
        public override void OnException(ExceptionContext context)
        {
            Exception ex = context.Exception;

            HttpExceptionResponseInfo info = Converter.GetMessageAndHttpCode(ex);

            context.HttpContext.Response.StatusCode = (int)info.Status;
            if (info.Message != null)
            {
                context.Result = new JsonResult(info.Message);
            }
        }