diff --git a/backend/windmill-api/src/job_helpers_oss.rs b/backend/windmill-api/src/job_helpers_oss.rs index 7a4fb7643a..f02ffbf29c 100644 --- a/backend/windmill-api/src/job_helpers_oss.rs +++ b/backend/windmill-api/src/job_helpers_oss.rs @@ -139,7 +139,7 @@ pub async fn download_s3_file_internal( pub async fn read_object_streamable( s3_client: Arc, file_key: &str, -) -> anyhow::Result { +) -> error::Result { Err(error::Error::internal_err( "Not implemented in Windmill's Open Source repository".to_string(), )) diff --git a/backend/windmill-common/src/error.rs b/backend/windmill-common/src/error.rs index 6418968d28..e5c95b7d82 100644 --- a/backend/windmill-common/src/error.rs +++ b/backend/windmill-common/src/error.rs @@ -286,3 +286,42 @@ where Self(err.into()) } } + +impl From for Error { + fn from(err: object_store::Error) -> Self { + use object_store::Error::*; + match err { + Generic { store, source } => Error::Generic( + StatusCode::INTERNAL_SERVER_ERROR, + format!("Generic {} error: {}", store, source), + ), + NotFound { path, source } => Error::NotFound(format!("{}: {}", path, source)), + InvalidPath { source } => Error::BadRequest(format!("Invalid path: {}", source)), + JoinError { source } => Error::InternalErr(format!("Join error: {}", source)), + NotSupported { source } => { + Error::BadRequest(format!("Operation not supported: {}", source)) + } + AlreadyExists { path, source } => { + Error::BadRequest(format!("Object at {} already exists: {}", path, source)) + } + Precondition { path, source } => { + Error::BadRequest(format!("Precondition failed at {}: {}", path, source)) + } + NotModified { path, source } => { + Error::ExecutionErr(format!("Not modified at {}: {}", path, source)) + } + NotImplemented => Error::BadRequest("Operation not yet implemented.".to_string()), + PermissionDenied { path, source } => { + Error::PermissionDenied(format!("Permission denied at {}: {}", path, source)) + } + Unauthenticated { path, source } => { + Error::NotAuthorized(format!("Unauthenticated for {}: {}", path, source)) + } + UnknownConfigurationKey { store, key } => Error::BadConfig(format!( + "Invalid config key '{}' for store '{}'", + key, store + )), + _ => Error::InternalErr(format!("Object store error: {}", err)), + } + } +}