Beispiel #1
0
 public void AddError(ErrorCode errorCode)
 {
     if (!Errors.Any(x => x.ErrorCode == errorCode))
     {
         Errors.Add(new Error
         {
             ErrorCode    = errorCode,
             ErrorMessage = LocalisationMessage.GetErrorMsg(errorCode)
         });
     }
 }
        public Response BuildErrorResponse(string message)
        {
            var errorCode = ErrorCode.UNEXPECTED_ERROR;

            Enum.TryParse(message, out errorCode);

            var errorResult = new
            {
                Errors = new List <object> {
                    new {
                        ErrorCode    = errorCode.ToString(),
                        ErrorMessage = LocalisationMessage.GetErrorMsg(errorCode.ToString())
                    }
                }
            };

            var responseString = JsonSerializer.ToJson(errorResult);

            _logger.Trace(responseString, correlationId: _correlationId.CurrentValue);

            return(new JsonResponse(errorResult, new DefaultJsonSerializer()));
        }