update error messages
Update error message to be more brief and compliant with C-GOOD-ERR
This commit is contained in:
parent
2deb63af10
commit
433711409e
149
src/errors.rs
149
src/errors.rs
|
@ -11,7 +11,7 @@ use chorus_macros::WebSocketEvent;
|
||||||
custom_error! {
|
custom_error! {
|
||||||
#[derive(PartialEq, Eq, Clone, Hash)]
|
#[derive(PartialEq, Eq, Clone, Hash)]
|
||||||
pub RegistrationError
|
pub RegistrationError
|
||||||
Consent = "Consent must be 'true' to register.",
|
Consent = "consent must be 'true' to register",
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ChorusResult<T> = std::result::Result<T, ChorusError>;
|
pub type ChorusResult<T> = std::result::Result<T, ChorusError>;
|
||||||
|
@ -20,33 +20,34 @@ custom_error! {
|
||||||
#[derive(Clone, Hash, PartialEq, Eq)]
|
#[derive(Clone, Hash, PartialEq, Eq)]
|
||||||
pub ChorusError
|
pub ChorusError
|
||||||
/// Server did not respond.
|
/// Server did not respond.
|
||||||
NoResponse = "Did not receive a response from the Server.",
|
NoResponse = "server did not respond",
|
||||||
/// Reqwest returned an Error instead of a Response object.
|
/// Reqwest returned an Error instead of a Response object.
|
||||||
RequestFailed{url:String, error: String} = "An error occurred while trying to GET from {url}: {error}",
|
RequestFailed{url:String, error: String} = "an error occurred while trying to GET from {url}: {error}",
|
||||||
/// Response received, however, it was not of the successful responses type. Used when no other, special case applies.
|
/// Response received, however, it was not of the successful responses type. Used when no other, special case applies.
|
||||||
ReceivedErrorCode{error_code: u16, error: String} = "Received the following error code while requesting from the route: {error_code}",
|
ReceivedErrorCode{error_code: u16, error: String} = "received error code while requesting from the route: {error_code}",
|
||||||
/// Used when there is likely something wrong with the instance, the request was directed to.
|
/// Used when there is likely something wrong with the instance, the request was directed to.
|
||||||
CantGetInformation{error:String} = "Something seems to be wrong with the instance. Cannot get information about the instance: {error}",
|
CantGetInformation{error:String} = "cannot get information about the instance: {error}, something is likely wrong with the instance",
|
||||||
/// The requests form body was malformed/invalid.
|
/// The requests form body was malformed/invalid.
|
||||||
InvalidFormBody{error_type: String, error:String} = "The server responded with: {error_type}: {error}",
|
InvalidFormBody{error_type: String, error:String} = "the server responded with: {error_type}: {error}",
|
||||||
/// The request has not been processed by the server due to a relevant rate limit bucket being exhausted.
|
/// The request has not been processed by the server due to a relevant rate limit bucket being exhausted.
|
||||||
RateLimited{bucket:String} = "Ratelimited on Bucket {bucket}",
|
RateLimited{bucket:String} = "ratelimited on bucket {bucket}",
|
||||||
/// The multipart form could not be created.
|
/// The multipart form could not be created.
|
||||||
MultipartCreation{error: String} = "Got an error whilst creating the form: {error}",
|
MultipartCreation{error: String} = "got an error whilst creating the form: {error}",
|
||||||
/// The regular form could not be created.
|
/// The regular form could not be created.
|
||||||
FormCreation{error: String} = "Got an error whilst creating the form: {error}",
|
FormCreation{error: String} = "got an error whilst creating the form: {error}",
|
||||||
/// The token is invalid.
|
/// The token is invalid.
|
||||||
TokenExpired = "Token expired, invalid or not found.",
|
TokenExpired = "token expired, invalid or not found",
|
||||||
/// No permission
|
/// No permission
|
||||||
NoPermission = "You do not have the permissions needed to perform this action.",
|
NoPermission = "you lack the permissions needed to perform this action",
|
||||||
/// Resource not found
|
/// Resource not found
|
||||||
NotFound{error: String} = "The provided resource hasn't been found: {error}",
|
NotFound{error: String} = "the provided resource wasn't found: {error}",
|
||||||
/// Used when you, for example, try to change your spacebar account password without providing your old password for verification.
|
/// Used when you, for example, try to change your spacebar account password without providing your old password for verification.
|
||||||
PasswordRequired = "You need to provide your current password to authenticate for this action.",
|
// RAGC: could this be worded a bit better to be more concise?
|
||||||
|
PasswordRequired = "you need to provide your current password to authenticate for this action",
|
||||||
/// Malformed or unexpected response.
|
/// Malformed or unexpected response.
|
||||||
InvalidResponse{error: String} = "The response is malformed and cannot be processed. Error: {error}",
|
InvalidResponse{error: String} = "the response is malformed and cannot be processed: {error}",
|
||||||
/// Invalid, insufficient or too many arguments provided.
|
/// Invalid, insufficient or too many arguments provided.
|
||||||
InvalidArguments{error: String} = "Invalid arguments were provided. Error: {error}"
|
InvalidArguments{error: String} = "invalid arguments were provided: {error}"
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<reqwest::Error> for ChorusError {
|
impl From<reqwest::Error> for ChorusError {
|
||||||
|
@ -61,12 +62,6 @@ impl From<reqwest::Error> for ChorusError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_error! {
|
|
||||||
#[derive(PartialEq, Eq)]
|
|
||||||
pub ObserverError
|
|
||||||
AlreadySubscribed = "Each event can only be subscribed to once."
|
|
||||||
}
|
|
||||||
|
|
||||||
custom_error! {
|
custom_error! {
|
||||||
/// For errors we receive from the gateway, see <https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#gateway-close-event-codes>;
|
/// For errors we receive from the gateway, see <https://discord-userdoccers.vercel.app/topics/opcodes-and-status-codes#gateway-close-event-codes>;
|
||||||
///
|
///
|
||||||
|
@ -77,27 +72,43 @@ custom_error! {
|
||||||
pub GatewayError
|
pub GatewayError
|
||||||
// Errors we have received from the gateway
|
// Errors we have received from the gateway
|
||||||
#[default]
|
#[default]
|
||||||
Unknown = "We're not sure what went wrong. Try reconnecting?",
|
/// We're not sure what went wrong. Try reconnecting?
|
||||||
UnknownOpcode = "You sent an invalid Gateway opcode or an invalid payload for an opcode",
|
Unknown = "unknown error occurred, try reconnecting",
|
||||||
Decode = "Gateway server couldn't decode payload",
|
/// You sent an invalid opcode or an invalid payload for an opcode
|
||||||
NotAuthenticated = "You sent a payload prior to identifying",
|
UnknownOpcode = "client sent invalid opcode or invalid payload for opcode",
|
||||||
AuthenticationFailed = "The account token sent with your identify payload is invalid",
|
/// Gateway server couldn't decode payload
|
||||||
AlreadyAuthenticated = "You've already identified, no need to reauthenticate",
|
Decode = "gateway server failed to decode payload",
|
||||||
InvalidSequenceNumber = "The sequence number sent when resuming the session was invalid. Reconnect and start a new session",
|
/// You sent a payload prior to identifying
|
||||||
RateLimited = "You are being rate limited!",
|
NotAuthenticated = "client sent payload before identifying",
|
||||||
SessionTimedOut = "Your session timed out. Reconnect and start a new one",
|
/// The account token sent with your identify payload is invalid
|
||||||
InvalidShard = "You sent us an invalid shard when identifying",
|
AuthenticationFailed = "account token in identify is invalid",
|
||||||
ShardingRequired = "The session would have handled too many guilds - you are required to shard your connection in order to connect",
|
/// You've already identified, no need to reauthenticate
|
||||||
InvalidAPIVersion = "You sent an invalid Gateway version",
|
AlreadyAuthenticated = "client sent more than one identify payload",
|
||||||
InvalidIntents = "You sent an invalid intent",
|
/// The sequence number sent when resuming the session was invalid. Reconnect and start a new session
|
||||||
DisallowedIntents = "You sent a disallowed intent. You may have tried to specify an intent that you have not enabled or are not approved for",
|
InvalidSequenceNumber = "sequence number when resuming session was invalid.",
|
||||||
|
/// You're being rate limited
|
||||||
|
RateLimited = "you are being rate limited",
|
||||||
|
/// Your session timed out. Reconnect and start a new one
|
||||||
|
SessionTimedOut = "session timed out",
|
||||||
|
/// You sent an invalid shard when identifying
|
||||||
|
InvalidShard = "invalid shard in identify",
|
||||||
|
/// The session would have handled too many guilds - you are required to shard your connection in order to connect
|
||||||
|
ShardingRequired = "sharding is required to connect",
|
||||||
|
/// You sent an invalid Gateway version
|
||||||
|
InvalidAPIVersion = "client sent invalid gateway version",
|
||||||
|
/// You sent an invalid intent
|
||||||
|
InvalidIntents = "invalid intent",
|
||||||
|
/// You sent a disallowed intent.
|
||||||
|
///
|
||||||
|
/// You may have tried to specify an intent that you have not enabled or are not approved for
|
||||||
|
DisallowedIntents = "disallowed (not enabled / approved) intent",
|
||||||
|
|
||||||
// Errors when initiating a gateway connection
|
// Errors when initiating a gateway connection
|
||||||
CannotConnect{error: String} = "Cannot connect due to a tungstenite error: {error}",
|
CannotConnect{error: String} = "encountered a tungstenite error: {error}",
|
||||||
NonHelloOnInitiate{opcode: u8} = "Received non hello on initial gateway connection ({opcode}), something is definitely wrong",
|
NonHelloOnInitiate{opcode: u8} = "received non hello on initializing connection: {opcode}",
|
||||||
|
|
||||||
// Other misc errors
|
// Other misc errors
|
||||||
UnexpectedOpcodeReceived{opcode: u8} = "Received an opcode we weren't expecting to receive: {opcode}",
|
UnexpectedOpcodeReceived{opcode: u8} = "unexpected opcode received: {opcode}",
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_error! {
|
custom_error! {
|
||||||
|
@ -110,25 +121,40 @@ custom_error! {
|
||||||
pub VoiceGatewayError
|
pub VoiceGatewayError
|
||||||
// Errors we receive
|
// Errors we receive
|
||||||
#[default]
|
#[default]
|
||||||
UnknownOpcode = "You sent an invalid opcode",
|
/// You sent an invalid opcode
|
||||||
FailedToDecodePayload = "You sent an invalid payload in your identifying to the (Voice) Gateway",
|
UnknownOpcode = "client sent invalid opcode",
|
||||||
NotAuthenticated = "You sent a payload before identifying with the (Voice) Gateway",
|
/// You sent an invalid payload in your identifying to the (Voice) Gateway
|
||||||
AuthenticationFailed = "The token you sent in your identify payload is incorrect",
|
FailedToDecodePayload = "server failed to decode payload while identifying",
|
||||||
AlreadyAuthenticated = "You sent more than one identify payload",
|
/// You sent a payload before identifying with the (Voice) Gateway
|
||||||
SessionNoLongerValid = "Your session is no longer valid",
|
NotAuthenticated = "client sent payload before identifying",
|
||||||
SessionTimeout = "Your session has timed out",
|
/// The token you sent in your identify payload is incorrect
|
||||||
ServerNotFound = "We can't find the server you're trying to connect to",
|
AuthenticationFailed = "account token in identify is invalid",
|
||||||
UnknownProtocol = "We didn't recognize the protocol you sent",
|
/// You sent more than one identify payload
|
||||||
Disconnected = "Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect.",
|
AlreadyAuthenticated = "client sent more than one identify payload",
|
||||||
VoiceServerCrashed = "The server crashed, try resuming",
|
/// Your session is no longer valid
|
||||||
UnknownEncryptionMode = "Server failed to decrypt data",
|
SessionNoLongerValid = "session no longer valid",
|
||||||
|
/// Your session has timed out
|
||||||
|
SessionTimeout = "session timed out",
|
||||||
|
/// Can't find the desired server to connect to
|
||||||
|
ServerNotFound = "desired server not found",
|
||||||
|
/// The server didn't recognize the protocol you sent
|
||||||
|
UnknownProtocol = "unrecognized or unknown protocol",
|
||||||
|
/// Channel was deleted, you were kicked, voice server changed, or the main gateway session
|
||||||
|
/// closed.
|
||||||
|
///
|
||||||
|
/// Should not attempt to reconnect.
|
||||||
|
Disconnected = "disconnected from voice",
|
||||||
|
/// The server crashed, try resuming
|
||||||
|
VoiceServerCrashed = "the voice server crashed",
|
||||||
|
/// Server failed to decrypt data
|
||||||
|
UnknownEncryptionMode = "server failed to decrypt / unknown encryption mode",
|
||||||
|
|
||||||
// Errors when initiating a gateway connection
|
// Errors when initiating a gateway connection
|
||||||
CannotConnect{error: String} = "Cannot connect due to a tungstenite error: {error}",
|
CannotConnect{error: String} = "encountered a tungstenite error: {error}",
|
||||||
NonHelloOnInitiate{opcode: u8} = "Received non hello on initial gateway connection ({opcode}), something is definitely wrong",
|
NonHelloOnInitiate{opcode: u8} = "received non hello on initializing connection: {opcode}",
|
||||||
|
|
||||||
// Other misc errors
|
// Other misc errors
|
||||||
UnexpectedOpcodeReceived{opcode: u8} = "Received an opcode we weren't expecting to receive: {opcode}",
|
UnexpectedOpcodeReceived{opcode: u8} = "unexpected opcode received: {opcode}",
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_error! {
|
custom_error! {
|
||||||
|
@ -138,17 +164,18 @@ custom_error! {
|
||||||
|
|
||||||
// General errors
|
// General errors
|
||||||
BrokenSocket{error: String} = "Could not write / read from UDP socket: {error}",
|
BrokenSocket{error: String} = "Could not write / read from UDP socket: {error}",
|
||||||
NoData = "We have not set received the necessary data to perform this operation.",
|
/// We have not yet received the necessary data to perform this operation.
|
||||||
|
NoData = "required data not yet received",
|
||||||
|
|
||||||
// Encryption errors
|
// Encryption errors
|
||||||
EncryptionModeNotImplemented{encryption_mode: String} = "Voice encryption mode {encryption_mode} is not yet implemented.",
|
EncryptionModeNotImplemented{encryption_mode: String} = "voice encryption mode {encryption_mode} is not yet implemented",
|
||||||
NoKey = "Tried to encrypt / decrypt rtp data, but no key has been received yet",
|
NoKey = "could not encrypt / decrypt data: no key received yet",
|
||||||
FailedEncryption = "Tried to encrypt rtp data, but failed. Most likely this is an issue chorus' nonce generation. Please open an issue on the chorus github: https://github.com/polyphony-chat/chorus/issues/new",
|
FailedEncryption = "failed to encrypt data (most likely this is an issue in chorus' nonce generation, please open an issue)",
|
||||||
FailedDecryption = "Tried to decrypt rtp data, but failed. Most likely this is an issue chorus' nonce generation. Please open an issue on the chorus github: https://github.com/polyphony-chat/chorus/issues/new",
|
FailedDecryption = "failed to decrypt data (most likely this is an issue in chorus' nonce generation, please open an issue)",
|
||||||
FailedNonceGeneration{error: String} = "Tried to generate nonce, but failed due to error: {error}.",
|
FailedNonceGeneration{error: String} = "failed to generate nonce: {error}.",
|
||||||
|
|
||||||
// Errors when initiating a socket connection
|
// Errors when initiating a socket connection
|
||||||
CannotBind{error: String} = "Cannot bind socket due to a UDP error: {error}",
|
CannotBind{error: String} = "failed to bind UDP socket: {error}",
|
||||||
CannotConnect{error: String} = "Cannot connect due to a UDP error: {error}",
|
CannotConnect{error: String} = "failed to open UDP connection: {error}",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue