Skip to main content

SaTokenError

Enum SaTokenError 

Source
pub enum SaTokenError {
Show 56 variants TokenNotFound, InvalidToken(String), TokenExpired, NotLogin, TokenInactive, PermissionDenied, PermissionDeniedDetail(String), RoleDenied(String), AccountBanned(String), AccountKickedOut, AccountReplaced, NotSafe(String), DisableService { service: String, level: i32, }, SessionNotFound, NonceAlreadyUsed, InvalidNonceFormat, InvalidNonceTimestamp, RefreshTokenNotFound, RefreshTokenInvalidData, RefreshTokenMissingLoginId, RefreshTokenInvalidExpireTime, TokenEmpty, TokenTooShort, LoginIdNotNumber, OAuth2ClientNotFound, OAuth2InvalidCredentials, OAuth2ClientIdMismatch, OAuth2RedirectUriMismatch, OAuth2CodeNotFound, OAuth2AccessTokenNotFound, OAuth2RefreshTokenNotFound, OAuth2InvalidRefreshToken, OAuth2InvalidScope, OAuth2PkceRequired, OAuth2PkceMismatch, OAuth2TokenRevokeFailed(String), OAuth2UnsupportedGrant, OAuth2PkceRequiredForPublicClient, InvalidTicket, TicketExpired, ServiceMismatch, SsoSessionNotFound, SsoSignInvalid, TerminalDenied { expected: String, actual: String, }, SameTokenInvalid, BasicAuthFailed { realm: String, }, SignInvalid, SignTimestampExpired, TempTokenNotFound, TempTokenExpired, NotInitialized, AlreadyInitialized, StorageError(String), ConfigError(String), SerializationError(String), InternalError(String),
}
Expand description

Unified error type for sa-token-core | sa-token-core 统一错误类型

Variants§

§

TokenNotFound

Token not found or expired | Token 不存在或已过期

§

InvalidToken(String)

Token value is invalid | Token 值无效

§

TokenExpired

Token has expired | Token 已过期

§

NotLogin

Caller is not logged in | 当前未登录

§

TokenInactive

Token exists but is inactive | Token 存在但未激活

§

PermissionDenied

Permission check failed | 权限校验失败

§

PermissionDeniedDetail(String)

Missing a specific permission | 缺少指定权限

§

RoleDenied(String)

Missing a specific role | 缺少指定角色

§

AccountBanned(String)

Account is banned until the given time | 账号被封禁至指定时间

§

AccountKickedOut

Account was kicked out | 账号已被踢下线

§

AccountReplaced

Login was replaced on another device | 账号在其他设备顶替登录

§

NotSafe(String)

Secondary authentication required | 需要二次认证

§

DisableService

Account disabled for a service at a level | 账号在某服务下被禁用

Fields

§service: String

Service name | 服务名

§level: i32

Disable level | 禁用等级

§

SessionNotFound

Session not found | Session 不存在

§

NonceAlreadyUsed

Nonce already consumed (possible replay) | Nonce 已使用(疑似重放)

§

InvalidNonceFormat

Nonce format is invalid | Nonce 格式无效

§

InvalidNonceTimestamp

Nonce timestamp invalid or expired | Nonce 时间戳无效或过期

§

RefreshTokenNotFound

Refresh token missing or expired | 刷新令牌不存在或过期

§

RefreshTokenInvalidData

Refresh token payload invalid | 刷新令牌数据无效

§

RefreshTokenMissingLoginId

Refresh token missing login_id | 刷新令牌缺少 login_id

§

RefreshTokenInvalidExpireTime

Refresh token expire time format invalid | 刷新令牌过期时间格式无效

§

TokenEmpty

Token string is empty | Token 为空

§

TokenTooShort

Token string is too short | Token 过短

§

LoginIdNotNumber

Login id is not a valid number | 登录 ID 不是合法数字

§

OAuth2ClientNotFound

OAuth2 client not found | OAuth2 客户端不存在

§

OAuth2InvalidCredentials

Invalid OAuth2 client credentials | OAuth2 客户端凭据无效

§

OAuth2ClientIdMismatch

OAuth2 client id mismatch | OAuth2 客户端 ID 不匹配

§

OAuth2RedirectUriMismatch

OAuth2 redirect URI mismatch | OAuth2 回调地址不匹配

§

OAuth2CodeNotFound

Authorization code missing or expired | 授权码不存在或过期

§

OAuth2AccessTokenNotFound

Access token missing or expired | 访问令牌不存在或过期

§

OAuth2RefreshTokenNotFound

Refresh token missing or expired | 刷新令牌不存在或过期

§

OAuth2InvalidRefreshToken

Invalid OAuth2 refresh token data | OAuth2 刷新令牌数据无效

§

OAuth2InvalidScope

Invalid OAuth2 scope data | OAuth2 scope 数据无效

§

OAuth2PkceRequired

PKCE code_verifier required | 需要 PKCE code_verifier

§

OAuth2PkceMismatch

PKCE verification failed | PKCE 校验失败

§

OAuth2TokenRevokeFailed(String)

Token revoke failed | 令牌吊销失败

§

OAuth2UnsupportedGrant

Unsupported OAuth2 grant type | 不支持的授权类型

§

OAuth2PkceRequiredForPublicClient

Public client must use PKCE S256 | 公共客户端必须使用 PKCE S256

§

InvalidTicket

SSO ticket not found or invalid | SSO ticket 不存在或无效

§

TicketExpired

SSO ticket expired | SSO ticket 已过期

§

ServiceMismatch

Service URL mismatch | 服务地址不匹配

§

SsoSessionNotFound

SSO session not found | SSO 会话不存在

§

SsoSignInvalid

SSO request signature invalid | SSO 请求签名无效

§

TerminalDenied

Device / terminal type is not allowed. 设备/终端类型不允许。

Fields

§expected: String

Allowed terminal pattern | 允许的终端模式

§actual: String

Actual terminal value | 实际终端值

§

SameTokenInvalid

Same-Token header missing or not matching current/past token. Same-Token 头缺失或与当前/宽限 token 不一致。

§

BasicAuthFailed

HTTP Basic credentials missing or mismatch. HTTP Basic 凭据缺失或不匹配。

Fields

§realm: String

Auth realm for WWW-Authenticate | WWW-Authenticate 的 realm

§

SignInvalid

Request signature does not match. 请求签名不匹配。

§

SignTimestampExpired

Request timestamp missing or outside the allowed window. 请求 timestamp 缺失或超出允许窗口。

§

TempTokenNotFound

Temp token missing or already deleted. 临时令牌不存在或已删除。

§

TempTokenExpired

Temp token past expire_at. 临时令牌已过 expire_at。

§

NotInitialized

全局 Manager 尚未初始化 Global manager has not been initialized

§

AlreadyInitialized

全局 Manager 重复初始化 Global manager was already initialized

§

StorageError(String)

Underlying storage failure | 底层存储失败

§

ConfigError(String)

Invalid configuration | 配置无效

§

SerializationError(String)

Serialization / deserialization failure | 序列化或反序列化失败

§

InternalError(String)

Unexpected internal failure | 未预期的内部错误

Implementations§

Source§

impl SaTokenError

Source

pub fn message(&self) -> String

Get the error message as a string.

Returns the English message from #[error(...)]. 返回 #[error(...)] 定义的英文文案。

§Examples
ⓘ
let err = SaTokenError::NotLogin;
assert_eq!(err.message(), "User not logged in");
Source

pub fn is_auth_error(&self) -> bool

Whether this is an authentication (login/token) error. 是否为认证(登录/Token)类错误。

Source

pub fn is_authz_error(&self) -> bool

Whether this is an authorization (permission/role) error. 是否为授权(权限/角色)类错误。

Trait Implementations§

Source§

impl Debug for SaTokenError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for SaTokenError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for SaTokenError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for SaTokenError

Source§

fn from(value: Error) -> SaTokenError

Converts to this type from the input type.
Source§

impl From<SerializerError> for SaTokenError

Source§

fn from(value: SerializerError) -> SaTokenError

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more