Skip to content

Commit 5080bf9

Browse files
authored
Refactor/cleanup errors (#179)
* error refactored: moved to thiserror * Result type alias for better ergonomics: * removed field from MinioErrorCode::BucketNotEmpty enum * made field private of MinioErrorResponse * updated XmlError * simplified calling errors * bumped toolchain channel form 1.86.0 to 1.87.0 * bumped toolchain channel form 1.87.0 to 1.88.0 due to clippy fixes that are not compatible with 1.87.0
1 parent e73fa10 commit 5080bf9

File tree

133 files changed

+2211
-1698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2211
-1698
lines changed

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ keywords = ["object-storage", "minio", "s3"]
1111
categories = ["api-bindings", "web-programming::http-client"]
1212

1313
[dependencies.reqwest]
14-
version = "0.12.18"
14+
version = "0.12.22"
1515
default-features = false
1616
features = ["stream"]
1717

@@ -51,19 +51,20 @@ regex = "1.11.1"
5151
ring = { version = "0.17.14", optional = true, default-features = false, features = ["alloc"] }
5252
serde = { version = "1.0.219", features = ["derive"] }
5353
serde_json = "1.0.140"
54-
sha2 = { version = "0.10.8", optional = true }
54+
sha2 = { version = "0.10.9", optional = true }
5555
urlencoding = "2.1.3"
5656
xmltree = "0.11.0"
5757
futures = "0.3.31"
5858
http = "1.3.1"
59+
thiserror = "2.0.12"
5960

6061
[dev-dependencies]
61-
tokio = { version = "1.45.1", features = ["full"] }
62+
tokio = { version = "1.47.1", features = ["full"] }
6263
minio_common = { path = "./common" }
6364
async-std = { version = "1.13.1", features = ["attributes", "tokio1"] }
64-
clap = { version = "4.5.40", features = ["derive"] }
65+
clap = { version = "4.5.44", features = ["derive"] }
6566
quickcheck = "1.0.3"
66-
criterion = "0.6.0"
67+
criterion = "0.7.0"
6768
minio-macros = { path = "./macros" }
6869

6970
[lib]

benches/s3/bench_object_append.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::common_benches::{Ctx2, benchmark_s3_api};
1717

1818
use criterion::Criterion;
1919
use minio::s3::builders::AppendObject;
20+
use minio::s3::error::Error;
2021
use minio::s3::response::StatObjectResponse;
2122
use minio::s3::segmented_bytes::SegmentedBytes;
2223
use minio::s3::types::S3Api;
@@ -38,8 +39,9 @@ pub(crate) async fn bench_object_append(criterion: &mut Criterion) {
3839
let data1: SegmentedBytes = SegmentedBytes::from(content1.to_string());
3940

4041
let resp: StatObjectResponse = task::block_in_place(|| {
41-
tokio::runtime::Runtime::new()?
42-
.block_on(ctx.client.stat_object(&ctx.bucket, &ctx.object).send())
42+
let runtime =
43+
tokio::runtime::Runtime::new().map_err(|e| Error::DriveIo(e.into()))?;
44+
runtime.block_on(ctx.client.stat_object(&ctx.bucket, &ctx.object).send())
4345
})
4446
.unwrap();
4547

benches/s3/common_benches.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use minio_common::utils::{
2424
get_bytes_from_response, get_response_from_bytes, rand_bucket_name, rand_object_name,
2525
};
2626
use std::env;
27-
2827
use tokio::runtime::Runtime;
2928

3029
pub(crate) struct Ctx2 {
@@ -170,7 +169,7 @@ pub(crate) fn benchmark_s3_api<ApiType, GlobalSetupFuture>(
170169
pub(crate) async fn skip_express_mode(bench_name: &str) -> bool {
171170
let skip = TestContext::new_from_env().client.is_minio_express().await;
172171
if skip {
173-
println!("Skipping benchmark '{}' (MinIO Express mode)", bench_name);
172+
println!("Skipping benchmark '{bench_name}' (MinIO Express mode)");
174173
}
175174
skip
176175
}

common/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ edition = "2024"
55

66
[dependencies]
77
minio = {path = ".." }
8-
tokio = { version = "1.45.1", features = ["full"] }
8+
tokio = { version = "1.47.1", features = ["full"] }
99
async-std = "1.13.1"
1010
rand = { version = "0.8.5", features = ["small_rng"] }
1111
bytes = "1.10.1"
1212
log = "0.4.27"
1313
chrono = "0.4.41"
14-
reqwest = "0.12.20"
14+
reqwest = "0.12.22"
1515
http = "1.3.1"
1616
futures = "0.3.31"
17-
uuid = { version = "1.17.0", features = ["v4"] }
17+
uuid = { version = "1.18.0", features = ["v4"] }
1818

1919
[lib]
2020
name = "minio_common"

common/src/cleanup_guard.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub async fn cleanup(client: Client, bucket_name: &str) {
4646
//eprintln!("Bucket {} removed successfully", bucket_name);
4747
}
4848
Err(e) => {
49-
eprintln!("Error removing bucket {}: {:?}", bucket_name, e);
49+
eprintln!("Error removing bucket '{}':\n{}", bucket_name, e);
5050
}
5151
}
5252
}

common/src/example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn create_bucket_notification_config_example() -> NotificationConfig {
4545
String::from("s3:ObjectCreated:Put"),
4646
String::from("s3:ObjectCreated:Copy"),
4747
],
48-
id: Some("".to_string()), //TODO or should this be NONE??
48+
id: None, //Some("".to_string()), //TODO or should this be NONE??
4949
prefix_filter_rule: Some(PrefixFilterRule {
5050
value: String::from("images"),
5151
}),

examples/append_object.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5757
offset_bytes += data_size;
5858
if resp.object_size() != offset_bytes {
5959
panic!(
60-
"from the append_object: size mismatch: expected {}, got {}",
60+
"from the append_object: size mismatch: expected {}, got {offset_bytes}",
6161
resp.object_size(),
62-
offset_bytes
6362
)
6463
}
65-
//println!("Append response: {:#?}", resp);
64+
//println!("Append response: {resp:#?}");
6665

6766
let resp: StatObjectResponse = client.stat_object(bucket_name, object_name).send().await?;
6867
if resp.size()? != offset_bytes {
6968
panic!(
70-
"from the stat_Object: size mismatch: expected {}, got {}",
69+
"from the stat_Object: size mismatch: expected {}, got {offset_bytes}",
7170
resp.size()?,
72-
offset_bytes
7371
)
7472
}
75-
println!("{}/{}", i, n_segments);
76-
//println!("Stat response: {:#?}", resp);
73+
println!("{i}/{n_segments}");
74+
//println!("Stat response: {resp:#?}");
7775
}
7876

7977
Ok(())

examples/bucket_encryption.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
3333
log::info!("encryption before: config={:?}", resp.config());
3434

3535
let config = SseConfig::default();
36-
log::info!("going to set encryption config={:?}", config);
36+
log::info!("going to set encryption config={config:?}");
3737

3838
let _resp: PutBucketEncryptionResponse = client
3939
.put_bucket_encryption(bucket_name)

examples/bucket_lifecycle.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
3535
// TODO
3636
let resp: GetBucketLifecycleResponse =
3737
client.get_bucket_lifecycle(bucket_name).send().await?;
38-
log::info!("life cycle settings before setting: resp={:?}", resp);
38+
log::info!("life cycle settings before setting: resp={resp:?}");
3939
}
4040

4141
let rules: Vec<LifecycleRule> = vec![LifecycleRule {
@@ -54,20 +54,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5454
.life_cycle_config(LifecycleConfig { rules })
5555
.send()
5656
.await?;
57-
log::info!("response of setting life cycle config: resp={:?}", resp);
57+
log::info!("response of setting life cycle config: resp={resp:?}");
5858

5959
if false {
6060
// TODO
6161
let resp: GetBucketLifecycleResponse =
6262
client.get_bucket_lifecycle(bucket_name).send().await?;
63-
log::info!("life cycle settings after setting: resp={:?}", resp);
63+
log::info!("life cycle settings after setting: resp={resp:?}");
6464
}
6565

6666
if false {
6767
// TODO
6868
let resp: DeleteBucketLifecycleResponse =
6969
client.delete_bucket_lifecycle(bucket_name).send().await?;
70-
log::info!("response of deleting lifecycle config: resp={:?}", resp);
70+
log::info!("response of deleting lifecycle config: resp={resp:?}");
7171
}
7272
Ok(())
7373
}

examples/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use minio::s3::{Client, ClientBuilder};
77
#[allow(dead_code)]
88
pub fn create_client_on_play() -> Result<Client, Box<dyn std::error::Error + Send + Sync>> {
99
let base_url = "https://play.min.io".parse::<BaseUrl>()?;
10-
log::info!("Trying to connect to MinIO at: `{:?}`", base_url);
10+
log::info!("Trying to connect to MinIO at: `{base_url:?}`");
1111

1212
let static_provider = StaticProvider::new(
1313
"Q3AM3UQ867SPQQA43P2F",
@@ -24,7 +24,7 @@ pub fn create_client_on_play() -> Result<Client, Box<dyn std::error::Error + Sen
2424
#[allow(dead_code)]
2525
pub fn create_client_on_localhost() -> Result<Client, Box<dyn std::error::Error + Send + Sync>> {
2626
let base_url = "http://localhost:9000/".parse::<BaseUrl>()?;
27-
log::info!("Trying to connect to MinIO at: `{:?}`", base_url);
27+
log::info!("Trying to connect to MinIO at: `{base_url:?}`");
2828

2929
let static_provider = StaticProvider::new("minioadmin", "minioadmin", None);
3030

0 commit comments

Comments
 (0)