mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-26 08:01:38 +00:00
convert object store error to wmill error for correct status code
This commit is contained in:
@@ -139,7 +139,7 @@ pub async fn download_s3_file_internal(
|
||||
pub async fn read_object_streamable(
|
||||
s3_client: Arc<dyn ObjectStore>,
|
||||
file_key: &str,
|
||||
) -> anyhow::Result<Response> {
|
||||
) -> error::Result<Response> {
|
||||
Err(error::Error::internal_err(
|
||||
"Not implemented in Windmill's Open Source repository".to_string(),
|
||||
))
|
||||
|
||||
@@ -286,3 +286,42 @@ where
|
||||
Self(err.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<object_store::Error> 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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user