Пример #1
0
        private BaeException parseError(BaeExceptionFormat err)
        {
            var reasons   = err.Reasons?.Select(r => parseError(r)) ?? new BaeException[0];
            var exception = new BaeException(err.Code, err.Meta, reasons);

            return(exception);
        }
Пример #2
0
        private BaeExceptionFormat parseException(BaeException ex)
        {
            var error = new BaeExceptionFormat
            {
                Code    = ex.Message,
                Meta    = parseExceptionData(ex.Data),
                Reasons = ex.InnerExceptions.Select(inner => parseException(inner as BaeException)),
            };

            // Aggregate Exceptions concatenate the "message" of every exception together
            // with a space as a seperator.. This is the way to ensure we get the first
            // error message, and none of the rest.

            var spaceIndex = error.Code.IndexOf(' ');

            if (spaceIndex > 0)
            {
                error.Code = error.Code.Remove(spaceIndex);
            }

            if (!error.Reasons.Any())
            {
                error.Reasons = null;
            }
            if (!error.Meta.Any())
            {
                error.Meta = null;
            }

            return(error);
        }