polyphony-chat / chorus

A Rust library for interacting with multiple Polyphony- and Spacebar-Compatible instances at once.
https://crates.io/crates/chorus
Mozilla Public License 2.0
16 stars 7 forks source link

Implement JSON error code handling #569

Open kozabrada123 opened 3 days ago

kozabrada123 commented 3 days ago

from https://docs.discord.sex/topics/opcodes-and-status-codes#json:

Along with the HTTP error code, the API can also return more detailed error codes through a code key in the JSON error response. The response will also contain a message key containing a more friendly error string. Some of these errors may include additional details in the form of Error Messages provided by an errors object.

This can help narrow down the error, for example in POST /users/@me/mfa/totp/enable:

{
    "message": "Invalid two-factor secret",
    "code": 60005
}

vs

{
    "message": "Password does not match",
    "code": 50018
}
bitfl0wer commented 3 days ago

symfonia should also implement this. I am going to create an issue there