Beispiel #1
0
        private IDictionary <string, string> GenerateErrorMessageData(ViewBaseException exception)
        {
            var data = new Dictionary <string, string>();

            data.Add("Code", exception.ErrorCode);
            data.Add("Message", string.Format(messageLoader.GetMessage(exception.ErrorCode), exception.Parameters.ToArray()));
            return(data);
        }
Beispiel #2
0
        public override void OnException(ExceptionContext context)
        {
            logger.LogError(context.Exception, context.Exception.GetBaseException().Message);

            context.ExceptionHandled = true;
            Exception exception = context.Exception;

            if (exception is ViewBaseException)
            {
            }
            else
            {
                exception = new ViewBaseException(ExceptionErrorCode.SystemUnhandledErrorCode);
            }

            var result = new BadRequestObjectResult(GenerateErrorMessageData((ViewBaseException)exception));

            logger.LogInformation("Service action exception happened: " + JsonConvert.SerializeObject(result));
            context.Result = result;
        }