Skip to content

Commit

Permalink
Merge pull request #13 from UniqueVision/box-error
Browse files Browse the repository at this point in the history
Box error
  • Loading branch information
aobatact authored Nov 8, 2024
2 parents 29475b1 + 5e14de7 commit 9685c29
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["dynamodb_utils", "s3_utils", "ssm_utils"]
resolver = "2"

[workspace.package]
version = "0.3.0"
version = "0.4.0"

[workspace.dependencies]
aws-config = { version = "1.5.8", features = ["behavior-version-latest"] }
Expand Down
18 changes: 15 additions & 3 deletions dynamodb_utils/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,25 @@ impl<A> Client<A> {
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
DynamoDb(#[from] aws_sdk_dynamodb::Error),
DynamoDb(Box<aws_sdk_dynamodb::Error>),
#[error(transparent)]
Serde(#[from] crate::serde_dynamo::Error),
Serde(Box<crate::serde_dynamo::Error>),
#[error("No Item")]
NotFound,
}

pub(crate) fn from_aws_sdk_dynamodb_error(e: impl Into<aws_sdk_dynamodb::Error>) -> Error {
Error::DynamoDb(e.into())
Error::DynamoDb(Box::new(e.into()))
}

impl From<aws_sdk_dynamodb::Error> for Error {
fn from(value: aws_sdk_dynamodb::Error) -> Self {
from_aws_sdk_dynamodb_error(value)
}
}

impl From<crate::serde_dynamo::Error> for Error {
fn from(value: crate::serde_dynamo::Error) -> Self {
Self::Serde(Box::new(value.into()))
}
}
2 changes: 1 addition & 1 deletion dynamodb_utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ where
for<'de> T: Deserialize<'de>,
{
raw_stream.and_then(|item| {
ready(crate::serde_dynamo::aws_sdk_dynamodb_1::from_item(item).map_err(Error::Serde))
ready(crate::serde_dynamo::aws_sdk_dynamodb_1::from_item(item).map_err(Into::into))
})
}
10 changes: 8 additions & 2 deletions s3_utils/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
S3(#[from] aws_sdk_s3::Error),
S3(Box<aws_sdk_s3::Error>),
#[error(transparent)]
PresigningConfig(#[from] aws_sdk_s3::presigning::PresigningConfigError),
#[error(transparent)]
Io(#[from] std::io::Error),
}

pub(crate) fn from_aws_sdk_s3_error(e: impl Into<aws_sdk_s3::Error>) -> Error {
Error::S3(e.into())
Error::S3(Box::new(e.into()))
}

impl From<aws_sdk_s3::Error> for Error {
fn from(value: aws_sdk_s3::Error) -> Self {
Self::S3(Box::new(value))
}
}
4 changes: 2 additions & 2 deletions ssm_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<C: Cache> Client<C> {
{
Error::NotFound
} else {
Error::Ssm(e.into())
Error::Ssm(Box::new(e.into()))
}
})?;
match resp.parameter.and_then(|it| it.value) {
Expand Down Expand Up @@ -117,5 +117,5 @@ pub enum Error {
#[error("Key not found")]
NotFound,
#[error(transparent)]
Ssm(sdk::Error),
Ssm(Box<sdk::Error>),
}

0 comments on commit 9685c29

Please sign in to comment.