60 lines
1.7 KiB
Rust
60 lines
1.7 KiB
Rust
//! Errors.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use std::fmt::Display;
|
|
|
|
/// An error.
|
|
#[derive(Debug, Clone, Serialize, Deserialize, thiserror::Error)]
|
|
pub enum Error {
|
|
/// Communication error.
|
|
#[error("communication error: {0}")]
|
|
Communication(String),
|
|
|
|
/// The specified method is not implemented.
|
|
#[error("`{0}`: Not implemented")]
|
|
NotImplemented(String),
|
|
|
|
/// Parameters are not suitable for the called method.
|
|
#[error("invalid parameters: {0}")]
|
|
InvalidParams(String),
|
|
|
|
/// The user has not enough permission to perform the action.
|
|
#[error("permission denied")]
|
|
PermissionDenied,
|
|
|
|
/// The operation operates on a user, but the specified user does not exist.
|
|
#[error("no such user")]
|
|
NoSuchUser,
|
|
|
|
/// The operation operates on a group, but the specified group does not exist.
|
|
#[error("no such group")]
|
|
NoSuchGroup,
|
|
|
|
/// The operation operates on a secret, but the specified secret does not exist.
|
|
#[error("no such secret")]
|
|
NoSuchSecret,
|
|
|
|
/// Attempted to launch an auth method that is not installed on current system.
|
|
#[error("no such auth method")]
|
|
NoSuchAuthMethod,
|
|
|
|
/// Attempted to authenticate/update authentication via an auth method that is not activated for the user.
|
|
///
|
|
/// **NOTE**: This does not imply that the auth method is installed on current system.
|
|
#[error("the specified auth method is not activated for the user")]
|
|
NotActivatedAuthMethod,
|
|
|
|
/// TODO
|
|
#[error("already exists")]
|
|
AlreadyExists,
|
|
|
|
/// An internal error.
|
|
#[error("internal error: {0}")]
|
|
Internal(String),
|
|
}
|
|
impl Error {
|
|
pub fn make_internal(x: impl Display) -> Self {
|
|
Self::Internal(x.to_string())
|
|
}
|
|
}
|