Skip to content

Commit 72417ff

Browse files
committed
Add some error details
1 parent 687141c commit 72417ff

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

crates/stackable-operator/src/commons/s3/helpers.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ impl S3ConnectionInlineOrReference {
3838
Self::Reference(reference) => Ok(client
3939
.get::<S3Connection>(&reference, namespace)
4040
.await
41-
.context(RetrieveS3ConnectionSnafu)?
41+
.context(RetrieveS3ConnectionSnafu {
42+
s3_connection: reference,
43+
})?
4244
.spec),
4345
}
4446
}
@@ -47,12 +49,12 @@ impl S3ConnectionInlineOrReference {
4749
impl ResolvedS3Connection {
4850
/// Build the endpoint URL from this connection
4951
pub fn endpoint(&self) -> Result<Url, S3Error> {
50-
let mut url = Url::parse(&format!(
52+
let endpoint = format!(
5153
"http://{host}:{port}",
5254
host = self.host.as_url_host(),
5355
port = self.port()
54-
))
55-
.context(ParseS3EndpointSnafu)?;
56+
);
57+
let mut url = Url::parse(&endpoint).context(ParseS3EndpointSnafu { endpoint })?;
5658

5759
if self.tls.uses_tls() {
5860
url.set_scheme("https").map_err(|_| {
@@ -172,7 +174,9 @@ impl S3BucketInlineOrReference {
172174
let bucket = client
173175
.get::<S3Bucket>(&reference, namespace)
174176
.await
175-
.context(RetrieveS3ConnectionSnafu)?
177+
.context(RetrieveS3ConnectionSnafu {
178+
s3_connection: reference,
179+
})?
176180
.spec;
177181
Ok(ResolvedS3Bucket {
178182
bucket_name: bucket.bucket_name,

crates/stackable-operator/src/commons/s3/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ use super::{secret_class::SecretClassVolumeError, tls_verification::TlsClientDet
1111

1212
#[derive(Debug, Snafu)]
1313
pub enum S3Error {
14-
#[snafu(display("failed to retrieve S3 connection"))]
15-
RetrieveS3Connection { source: crate::client::Error },
16-
17-
#[snafu(display("failed to parse S3 endpoint"))]
18-
ParseS3Endpoint { source: url::ParseError },
14+
#[snafu(display("failed to retrieve S3 connection '{s3_connection}'"))]
15+
RetrieveS3Connection {
16+
source: crate::client::Error,
17+
s3_connection: String,
18+
},
19+
20+
#[snafu(display("failed to parse S3 endpoint '{endpoint}'"))]
21+
ParseS3Endpoint {
22+
source: url::ParseError,
23+
endpoint: String,
24+
},
1925

2026
#[snafu(display("failed to set S3 endpoint scheme '{scheme}' for endpoint '{endpoint}'"))]
2127
SetS3EndpointScheme { endpoint: Url, scheme: String },

0 commit comments

Comments
 (0)