refactor(apiv2): fix nonsense behaviour with error objects/arrays
This commit is contained in:
parent
8e0e393f52
commit
93eef82a83
@ -54,21 +54,11 @@ namespace PluralKit.API
|
|||||||
else
|
else
|
||||||
o.Add("message", $"Field {err.Key} is invalid.");
|
o.Add("message", $"Field {err.Key} is invalid.");
|
||||||
|
|
||||||
if (e[err.Key] != null)
|
if (e[err.Key] == null)
|
||||||
{
|
|
||||||
if (e[err.Key].Type == JTokenType.Object)
|
|
||||||
{
|
|
||||||
var current = e[err.Key];
|
|
||||||
e.Remove(err.Key);
|
|
||||||
e.Add(err.Key, new JArray());
|
e.Add(err.Key, new JArray());
|
||||||
(e[err.Key] as JArray).Add(current);
|
|
||||||
}
|
|
||||||
|
|
||||||
(e[err.Key] as JArray).Add(o);
|
(e[err.Key] as JArray).Add(o);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
e.Add(err.Key, o);
|
|
||||||
}
|
|
||||||
|
|
||||||
j.Add("errors", e);
|
j.Add("errors", e);
|
||||||
return j;
|
return j;
|
||||||
|
@ -13,10 +13,10 @@ When something goes wrong, the API will send back a 4xx HTTP status code, along
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
|code|int|numerical error code|
|
|code|int|numerical error code|
|
||||||
|message|string|description of the error|
|
|message|string|description of the error|
|
||||||
|?errors|map of keys to error objects*|details on the error|
|
|?errors|map of entity keys to list of error objects*|details on the error|
|
||||||
|?retry_after|int|if this is a rate limit error, the number of milliseconds after which you can retry the request|
|
|?retry_after|int|if this is a rate limit error, the number of milliseconds after which you can retry the request|
|
||||||
|
|
||||||
* Only returned for model parsing errors. Values can be individual error objects, or arrays of error objects.
|
* Only returned for model parsing errors.
|
||||||
|
|
||||||
### Error Object
|
### Error Object
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user