chorus/src/errors.rs

33 lines
1.6 KiB
Rust
Raw Normal View History

2023-04-21 16:18:20 +02:00
use custom_error::custom_error;
custom_error! {
#[derive(PartialEq, Eq)]
2023-04-21 23:20:23 +02:00
pub FieldFormatError
2023-04-21 16:18:20 +02:00
PasswordError = "Password must be between 1 and 72 characters.",
UsernameError = "Username must be between 2 and 32 characters.",
ConsentError = "Consent must be 'true' to register.",
2023-04-22 11:32:44 +02:00
EmailError = "The provided email address is in an invalid format.",
2023-04-21 16:18:20 +02:00
}
2023-04-21 18:20:49 +02:00
custom_error! {
#[derive(PartialEq, Eq)]
pub InstanceServerError
2023-04-21 23:20:23 +02:00
NoResponse = "Did not receive a response from the Server.",
RequestErrorError{url:String, error:String} = "An error occured while trying to GET from {url}: {error}",
ReceivedErrorCodeError{error_code:String} = "Received the following error code while requesting from the route: {error_code}",
2023-04-22 11:32:44 +02:00
CantGetInfoError{error:String} = "Something seems to be wrong with the instance. Cannot get information about the instance: {error}",
2023-04-22 22:12:56 +02:00
InvalidFormBodyError{error_type: String, error:String} = "The server responded with: {error_type}: {error}",
2023-05-14 13:12:02 +02:00
RateLimited{bucket:String} = "Ratelimited on Bucket {bucket}",
2023-05-11 00:06:13 +02:00
MultipartCreationError{error: String} = "Got an error whilst creating the form: {}",
TokenExpired = "Token expired, invalid or not found.",
NoPermission = "You do not have the permissions needed to perform this action.",
2023-05-14 14:16:21 +02:00
NotFound{error: String} = "The provided resource hasn't been found: {}",
2023-05-16 15:58:51 +02:00
PasswordRequiredError = "You need to provide your current password to authenticate for this action.",
2023-04-21 18:20:49 +02:00
}
2023-04-27 22:38:57 +02:00
custom_error! {
#[derive(PartialEq, Eq)]
pub ObserverError
AlreadySubscribedError = "Each event can only be subscribed to once."
}