-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(http)!: cleanup ApiError
#1737
base: old-next
Are you sure you want to change the base?
refactor(http)!: cleanup ApiError
#1737
Conversation
The other variants were only useful prior to the API V8 error changes.
I'm unsure I understand this PR. Doesn't this remove support for parsing field errors? https://discord.com/developers/docs/reference#error-messages |
Let's analyze these fields. The error message is not something users are supposed to match on, and it's already provided through the Display implementation on This leaves the JSON error code, global and retry_after. enum ApiError {
Code(u64),
Ratelimit(Ratelimit),
}
struct Ratelimit {
global: bool,
retry_after: f64,
} |
Also I dislike the |
ApiError
In what way is it out of date? If it is, shouldn't we get it up to date? These object and array error messages detailing form body errors are still returned by the API |
I thought they were replaced/deprecated in API v8, other API error responses are also undocumented which makes it look unsupported to me. |
Quite the opposite, they were introduced in API v8. If you send this request: echo '{"embeds": [{"type": "rich"}]}' | http post https://discord.com/api/v10/channels/:id/messages You'll get this response: {
"code": 50035,
"errors": {
"embeds": {
"0": {
"description": {
"_errors": [
{
"code": "BASE_TYPE_REQUIRED",
"message": "This field is required"
}
]
}
}
}
},
"message": "Invalid Form Body"
} This response is what the MessageApiError variant attempted to do, perhaps incorrectly. I would rather we fix that than remove it, as it is a documented structure in the API. I can understand if you're not enthusiastic about that, so I can do that if you'd like |
So is the Array, Object and Response types stable? I.e. |
Triage: deferring research to after 0.15 |
This is more or less correct according to Discords OpenAPI spec |
It's other variants are outdated, and the
message
field is covered by theDisplay
impl onError
.