示例#1
0
        public DiscordHttpException(DiscordHttpError error) : base($"{(int)error.Code} {error.Message}")
        {
            Code         = error.Code;
            ErrorMessage = error.Message;

            if (error.Fields != null)
            {
                InvalidFields = FindErrors(error.Fields);
            }
        }
示例#2
0
        private static FieldErrorDictionary FindErrors(JObject obj)
        {
            var dict = new FieldErrorDictionary();

            foreach (JProperty child in obj.Children())
            {
                if (child.Name == "_errors")
                {
                    dict.Errors = child.Value.ToObject <List <DiscordFieldError> >();
                }
                else
                {
                    dict[child.Name] = FindErrors((JObject)child.Value);
                }
            }

            return(dict);
        }