add file
This commit is contained in:
parent
b4b4f837cf
commit
b8e1235396
36
src/types/error_code.rs
Normal file
36
src/types/error_code.rs
Normal file
@ -0,0 +1,36 @@
|
||||
#[non_exhaustive]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ErrorCode {
|
||||
Forbidden,
|
||||
UnknownToken,
|
||||
MissingToken,
|
||||
BadJson,
|
||||
NotJson,
|
||||
NotFound,
|
||||
LimitExceeded,
|
||||
Unknown,
|
||||
UserInUse,
|
||||
InvalidUsername,
|
||||
Exclusive,
|
||||
}
|
||||
|
||||
impl serde::Serialize for ErrorCode {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.serialize_str(match self {
|
||||
ErrorCode::Forbidden => "M_FORBIDDEN",
|
||||
ErrorCode::UnknownToken => "M_UNKNOWN_TOKEN",
|
||||
ErrorCode::MissingToken => "M_MISSING_TOKEN",
|
||||
ErrorCode::BadJson => "M_BAD_JSON",
|
||||
ErrorCode::NotJson => "M_NOT_JSON",
|
||||
ErrorCode::NotFound => "M_NOT_FOUND",
|
||||
ErrorCode::LimitExceeded => "M_LIMIT_EXCEEDED",
|
||||
ErrorCode::Unknown => "M_UNKNOWN",
|
||||
ErrorCode::UserInUse => "M_USER_IN_USE",
|
||||
ErrorCode::InvalidUsername => "M_INVALID_USERNAME",
|
||||
ErrorCode::Exclusive => "M_EXCLUSIVE",
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user