Esempio n. 1
0
        public static string ToUserFriendlyString(this Exception ex)
        {
            var trimmed = Guard.Correct(ex.Message);

            if (trimmed.Length == 0)
            {
                return(ex.ToTypeMessageString());
            }
            else
            {
                if (ex is HwiException hwiEx && hwiEx.ErrorCode == HwiErrorCode.DeviceConnError)
                {
                    return("Could not find the hardware wallet.\nMake sure it is connected.");
                }

                foreach (KeyValuePair <string, string> pair in Translations)
                {
                    if (trimmed.Contains(pair.Key, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(pair.Value);
                    }
                }

                return(ex.ToTypeMessageString());
            }
        }
Esempio n. 2
0
        public static string ToTypeMessageString(this Exception ex)
        {
            var trimmed = Guard.Correct(ex.Message);

            return(trimmed == ""
                                ? ex.GetType().Name
                                : $"{ex.GetType().Name}: {ex.Message}");
        }
Esempio n. 3
0
        public static string ToTypeMessageString(this Exception ex)
        {
            var trimmed = Guard.Correct(ex.Message);

            if (trimmed.Length == 0)
            {
                if (ex is HwiException hwiEx)
                {
                    return($"{hwiEx.GetType().Name}: {hwiEx.ErrorCode}");
                }
                return(ex.GetType().Name);
            }
            else
            {
                return($"{ex.GetType().Name}: {ex.Message}");
            }
        }
Esempio n. 4
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());
            }
        }