Skip to main content

potree_auth/project_asset/http/
error.rs

1use super::super::application::error::ProjectAssetsServiceError;
2use crate::common::utils::http::api_error::ApiError;
3
4impl From<ProjectAssetsServiceError> for ApiError {
5    fn from(value: ProjectAssetsServiceError) -> Self {
6        match value {
7            ProjectAssetsServiceError::ProjectNotFound { id } => Self::ResourceNotFound {
8                resource_name: format!("project: {id}"),
9            },
10            ProjectAssetsServiceError::NotAuthorized {
11                user,
12                action,
13                resource_identifier,
14                resource_type,
15            } => Self::NotAuthorized {
16                user,
17                action,
18                resource_identifier,
19                resource_type,
20            },
21            ProjectAssetsServiceError::NotAuthenticated => Self::NotAuthenticated,
22            ProjectAssetsServiceError::AssetNotFound { path } => Self::ResourceNotFound {
23                resource_name: path.to_string_lossy().to_string(),
24            },
25            ProjectAssetsServiceError::Infrastucture { message } => Self::Infrastucture { message },
26        }
27    }
28}