pub struct BaseException {
pub code: i32,
pub msg: String,
}Expand description
BaseException — 对齐 PHP app\common\exception\BaseException
PHP 原始实现:
class BaseException extends Exception {
public $code = 0;
public $message = 'invalid parameters';
public function __construct($params = []) {
if (array_key_exists('code', $params)) { $this->code = $params['code']; }
if (array_key_exists('msg', $params)) { $this->message = $params['msg']; }
}
}Fields§
§code: i32错误码(对齐 PHP $code)
msg: String错误消息(对齐 PHP $message,PHP 用 msg 键传入)
Implementations§
Source§impl BaseException
impl BaseException
Sourcepub fn new(code: ErrorCode, msg: impl Into<String>) -> Self
pub fn new(code: ErrorCode, msg: impl Into<String>) -> Self
创建 BaseException(对齐 PHP new BaseException(['code' => x, 'msg' => y]))
Sourcepub fn not_login(msg: impl Into<String>) -> Self
pub fn not_login(msg: impl Into<String>) -> Self
未登录快捷构造(对齐 PHP throw new BaseException(['code' => -1, 'msg' => 'not_login']))
Sourcepub fn user_not_found(msg: impl Into<String>) -> Self
pub fn user_not_found(msg: impl Into<String>) -> Self
用户不存在快捷构造(对齐 PHP throw new BaseException(['msg' => '没有找到用户信息', 'code' => -2]))
Sourcepub fn user_disabled(msg: impl Into<String>) -> Self
pub fn user_disabled(msg: impl Into<String>) -> Self
用户已禁用快捷构造(对齐 PHP throw new BaseException(['msg' => '您已离职', 'code' => -3]))
Sourcepub fn validate_failed(msg: impl Into<String>) -> Self
pub fn validate_failed(msg: impl Into<String>) -> Self
验证失败快捷构造
Trait Implementations§
Source§impl Clone for BaseException
impl Clone for BaseException
Source§fn clone(&self) -> BaseException
fn clone(&self) -> BaseException
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BaseException
impl Debug for BaseException
Source§impl Default for BaseException
impl Default for BaseException
Source§impl Display for BaseException
impl Display for BaseException
Source§impl Error for BaseException
impl Error for BaseException
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<GuardError> for BaseException
impl From<GuardError> for BaseException
Source§fn from(err: GuardError) -> Self
fn from(err: GuardError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for BaseException
impl RefUnwindSafe for BaseException
impl Send for BaseException
impl Sync for BaseException
impl Unpin for BaseException
impl UnsafeUnpin for BaseException
impl UnwindSafe for BaseException
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.