pub struct ErrorCode {
pub code: i64,
pub message: &'static str,
}Fields§
§code: i64§message: &'static strImplementations§
Source§impl ErrorCode
impl ErrorCode
pub fn new(code: i64, message: &'static str) -> ErrorCode
pub fn code(&self) -> i64
pub fn code_string(&self) -> Option<String>
pub fn message(&self) -> &'static str
Sourcepub fn tips(&self, tips: &'static str) -> String
pub fn tips(&self, tips: &'static str) -> String
Examples
async fn test(req: actix_web::HttpRequest) -> impl Responder {
let tips = errcode::NOT_EXIST.tips("gg");
return ...;
}Sourcepub fn throw_tips(
&self,
req: &HttpRequest,
tips: &'static str,
) -> HttpResponse<<Response<ErrorCode> as Responder>::Body>
pub fn throw_tips( &self, req: &HttpRequest, tips: &'static str, ) -> HttpResponse<<Response<ErrorCode> as Responder>::Body>
Examples
async fn test(req: actix_web::HttpRequest) -> impl Responder {
return errcode::NOT_EXIST.throw_tips(&req, "gg");
}Sourcepub fn throw(
&self,
req: &HttpRequest,
) -> HttpResponse<<Response<ErrorCode> as Responder>::Body>
pub fn throw( &self, req: &HttpRequest, ) -> HttpResponse<<Response<ErrorCode> as Responder>::Body>
Examples
async fn test(req: actix_web::HttpRequest) -> impl Responder {
return errcode::VALID_CODE_ERROR.throw(&req);
}Trait Implementations§
Source§impl ResponseError for ErrorCode
impl ResponseError for ErrorCode
Source§fn error_response(&self) -> HttpResponse
fn error_response(&self) -> HttpResponse
Creates full response for error. Read more
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Returns appropriate status code for error. Read more
Auto Trait Implementations§
impl Freeze for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
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