private CrpcException parseError(CrpcExceptionFormat err)
        {
            var reasons   = err.Reasons?.Select(r => parseError(r)) ?? new CrpcException[0];
            var exception = new CrpcException(err.Code, err.Meta, reasons);

            return(exception);
        }
        private CrpcExceptionFormat parseException(CrpcException ex)
        {
            var error = new CrpcExceptionFormat
            {
                Code    = ex.Message,
                Meta    = parseExceptionData(ex.Data),
                Reasons = ex.InnerExceptions.Select(inner => parseException(inner as CrpcException)),
            };

            // 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);
        }