Пример #1
0
        public static string ToUserFriendlyString(this HttpRequestException ex)
        {
            var trimmed = Guard.Correct(ex.Message);

            if (trimmed == "")
            {
                return(ex.ToTypeMessageString());
            }
            else
            {
                foreach (KeyValuePair <string, string> pair in BitcoinCoreTranslations)
                {
                    if (trimmed.Contains(pair.Key, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(pair.Value);
                    }
                }

                return(ex.ToTypeMessageString());
            }
        }
        public static string ToUserFriendlyString(this HttpRequestException ex)
        {
            var transalations = new Dictionary <string, string>
            {
                ["too-long-mempool-chain"]         = "At least one coin you are trying to spend is part of long chain of unconfirmed transactions. You must wait for some previous transactions to confirm.",
                ["bad-txns-inputs-missingorspent"] = "At least one coin you are trying to spend is already spent.",
                ["missing-inputs"]            = "At least one coin you are trying to spend is already spent.",
                ["bad-txns-inputs-duplicate"] = "The transaction contains duplicated inputs.",
                ["bad-txns-nonfinal"]         = "The transaction is not final and cannot be broadcasted.",
                ["bad-txns-oversize"]         = "The transaction is too big."
            };

            var msg = ex.Message.Substring(0, ex.Message.IndexOf(','));

            if (transalations.ContainsKey(msg))
            {
                return(transalations[msg]);
            }
            return(ex.ToTypeMessageString());
        }