mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor(apiv2): fix nonsense behaviour with error objects/arrays
This commit is contained in:
parent
8e0e393f52
commit
93eef82a83
2 changed files with 5 additions and 15 deletions
|
|
@ -54,20 +54,10 @@ namespace PluralKit.API
|
|||
else
|
||||
o.Add("message", $"Field {err.Key} is invalid.");
|
||||
|
||||
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[err.Key] as JArray).Add(current);
|
||||
}
|
||||
if (e[err.Key] == null)
|
||||
e.Add(err.Key, new JArray());
|
||||
|
||||
(e[err.Key] as JArray).Add(o);
|
||||
}
|
||||
else
|
||||
e.Add(err.Key, o);
|
||||
(e[err.Key] as JArray).Add(o);
|
||||
}
|
||||
|
||||
j.Add("errors", e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue