Nathan.fooo 058eeec932
feat: implement file storage using appflowy cloud (#3675)
* feat: implement file storage using appflowy cloud

* chore: clippy
2023-10-12 09:54:45 +08:00

30 lines
1.5 KiB
Rust

use client_api::error::AppError;
use crate::{ErrorCode, FlowyError};
impl From<AppError> for FlowyError {
fn from(error: AppError) -> Self {
let code = match error.code {
client_api::error::ErrorCode::Ok => ErrorCode::Internal,
client_api::error::ErrorCode::Unhandled => ErrorCode::Internal,
client_api::error::ErrorCode::RecordNotFound => ErrorCode::RecordNotFound,
client_api::error::ErrorCode::RecordAlreadyExists => ErrorCode::RecordAlreadyExists,
client_api::error::ErrorCode::InvalidEmail => ErrorCode::EmailFormatInvalid,
client_api::error::ErrorCode::InvalidPassword => ErrorCode::PasswordFormatInvalid,
client_api::error::ErrorCode::OAuthError => ErrorCode::UserUnauthorized,
client_api::error::ErrorCode::MissingPayload => ErrorCode::MissingPayload,
client_api::error::ErrorCode::OpenError => ErrorCode::Internal,
client_api::error::ErrorCode::InvalidUrl => ErrorCode::InvalidURL,
client_api::error::ErrorCode::InvalidRequestParams => ErrorCode::InvalidParams,
client_api::error::ErrorCode::UrlMissingParameter => ErrorCode::InvalidParams,
client_api::error::ErrorCode::InvalidOAuthProvider => ErrorCode::InvalidAuthConfig,
client_api::error::ErrorCode::NotLoggedIn => ErrorCode::UserUnauthorized,
client_api::error::ErrorCode::NotEnoughPermissions => ErrorCode::NotEnoughPermissions,
client_api::error::ErrorCode::UserNameIsEmpty => ErrorCode::UserNameIsEmpty,
_ => ErrorCode::Internal,
};
FlowyError::new(code, error.message)
}
}