ServiceStack.HttpResponseExtensionsInternal.ToErrorResponse C# (CSharp) Метод

ToErrorResponse() приватный статический Метод

private static ToErrorResponse ( this ex ) : ServiceStack.ErrorResponse
ex this
Результат ServiceStack.ErrorResponse
        private static ErrorResponse ToErrorResponse(this Exception ex)
        {
            List<ResponseError> errors = null;

            // For some exception types, we'll need to extract additional information in debug mode
            // (for example, so people can fix errors in their pages).
            if (HostContext.DebugMode)
            {
#if !NETSTANDARD1_6
                var compileEx = ex as HttpCompileException;
                if (compileEx != null && compileEx.Results.Errors.HasErrors)
                {
                    errors = new List<ResponseError>();
                    foreach (var err in compileEx.Results.Errors)
                    {
                        errors.Add(new ResponseError { Message = err.ToString() });
                    }
                }
#endif
            }

            var dto = new ErrorResponse
            {
                ResponseStatus = new ResponseStatus
                {
                    ErrorCode = ex.ToErrorCode(),
                    Message = ex.Message,
                    StackTrace = HostContext.DebugMode ? ex.StackTrace : null,
                    Errors = errors
                }
            };
            return dto;
        }