Skip to content

Commit

Permalink
better error handle
Browse files Browse the repository at this point in the history
  • Loading branch information
fankaiLiu committed Nov 24, 2023
1 parent edeaec7 commit e4650a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
18 changes: 1 addition & 17 deletions src/template/src/app_error.hbs
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
{{#if is_web_site}}
use salvo::{
async_trait,
http::ParseError,
prelude::{EndpointOutRegister, StatusCode},
writing::Json,
Depot, Request, Response, Writer,
};
{{else}}
use salvo::{
async_trait,
http::ParseError,
prelude::EndpointOutRegister,
writing::Json,
Depot, Request, Response, Writer,
};
{{/if}}
use salvo::http::ParseError;
{{#if is_mongodb}}
use mongodb::bson::document::ValueAccessError as MongoBsonAccessError;
use mongodb::bson::oid::Error as MongoBsonOidError;
Expand Down
2 changes: 1 addition & 1 deletion src/template/src/routers/user.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub async fn get_users() -> AppResponse<Vec<UserResponse>> {

{{else}}
use crate::{
app_error::AppResult,
app_response::AppResult,
app_response::{ErrRes, Res},
dtos::user::{UserAddRequest, UserLoginRequest, UserLoginResponse, UserUpdateRequest},
services::user,
Expand Down
8 changes: 4 additions & 4 deletions src/template/src/services/user.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#if is_sea_orm_or_sqlx}}
{{#if is_sqlx}}
use crate::{
app_error::AppResult,
app_response::AppResult,
db::DB,
dtos::user::{
UserAddRequest, UserLoginRequest, UserLoginResponse, UserResponse,
Expand All @@ -14,7 +14,7 @@ use crate::{
{{/if}}
{{#if is_sea_orm}}
use crate::{
app_error::AppResult,
app_response::AppResult,
db::DB,
dtos::user::{
UserAddRequest, UserLoginRequest, UserLoginResponse, UserResponse,
Expand Down Expand Up @@ -223,7 +223,7 @@ use uuid::Uuid;

use crate::schema::users::dsl::users as diesel_users;
use crate::{
app_error::AppResult,
app_response::AppResult,
db::establish_connection,
dtos::user::{
UserAddRequest, UserLoginRequest, UserLoginResponse, UserResponse, UserUpdateRequest,
Expand Down Expand Up @@ -355,7 +355,7 @@ pub async fn users() -> AppResult<Vec<UserResponse>> {
use uuid::Uuid;

use crate::{
app_error::AppResult,
app_response::AppResult,
dtos::user::{
UserAddRequest, UserLoginRequest, UserLoginResponse, UserResponse, UserUpdateRequest,
},
Expand Down

0 comments on commit e4650a6

Please sign in to comment.