feat: introduce ApiError for improved error handling in upstream routes

This commit is contained in:
GW_MC
2025-12-29 18:03:09 +08:00
parent abeea4fad7
commit fdfd1c98e0
4 changed files with 26 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::{
errors::service_error::ServiceError,
errors::{api_error::ApiError, service_error::ServiceError},
routes::{
AppState,
api::{
@@ -64,7 +64,7 @@ pub async fn get_upstream(
Path(upstream_id): Path<Uuid>,
Query(params): Query<GetUpstreamParams>,
State(_state): State<Arc<AppState>>,
) -> AxumResult<Json<UpstreamInfoResponse>, ServiceError> {
) -> AxumResult<Json<UpstreamInfoResponse>, ApiError> {
let concrete_params: ConcreteGetUpstreamParams = params.into();
let upstream_service = &_state.service.nginx.get_upstream_service();
let upstream_info = if concrete_params.include_targets {

View File

@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::{
errors::service_error::ServiceError,
errors::{api_error::ApiError, service_error::ServiceError},
routes::{AppState, api::restricted::nginx::upstream::info::response::UpstreamTargetInfo},
};
@@ -34,7 +34,7 @@ pub async fn get_upstream_target(
Path(upstream_target_id): Path<Uuid>,
Query(params): Query<GetUpstreamTargetsParams>,
State(_state): State<Arc<AppState>>,
) -> AxumResult<Json<UpstreamTargetInfo>, ServiceError> {
) -> AxumResult<Json<UpstreamTargetInfo>, ApiError> {
let concrete_params: ConcreteGetUpstreamTargetsParams = params.into();
let upstream_service = &_state.service.nginx.get_upstream_service();
let upstream_target_info = upstream_service