From e4650a645724b5c1cb18ceeca715304e3461d441 Mon Sep 17 00:00:00 2001 From: Fankai Liu Date: Fri, 24 Nov 2023 20:38:13 +0800 Subject: [PATCH] better error handle --- src/template/src/app_error.hbs | 18 +----------------- src/template/src/routers/user.hbs | 2 +- src/template/src/services/user.hbs | 8 ++++---- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/template/src/app_error.hbs b/src/template/src/app_error.hbs index f1360f3..ee04f52 100644 --- a/src/template/src/app_error.hbs +++ b/src/template/src/app_error.hbs @@ -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; diff --git a/src/template/src/routers/user.hbs b/src/template/src/routers/user.hbs index a9b6728..7312399 100644 --- a/src/template/src/routers/user.hbs +++ b/src/template/src/routers/user.hbs @@ -106,7 +106,7 @@ pub async fn get_users() -> AppResponse> { {{else}} use crate::{ - app_error::AppResult, + app_response::AppResult, app_response::{ErrRes, Res}, dtos::user::{UserAddRequest, UserLoginRequest, UserLoginResponse, UserUpdateRequest}, services::user, diff --git a/src/template/src/services/user.hbs b/src/template/src/services/user.hbs index a3a2cc1..57ae11f 100644 --- a/src/template/src/services/user.hbs +++ b/src/template/src/services/user.hbs @@ -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, @@ -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, @@ -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, @@ -355,7 +355,7 @@ pub async fn users() -> AppResult> { use uuid::Uuid; use crate::{ - app_error::AppResult, + app_response::AppResult, dtos::user::{ UserAddRequest, UserLoginRequest, UserLoginResponse, UserResponse, UserUpdateRequest, },