Skip to content

Commit

Permalink
Credentials error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
gr211 committed Oct 20, 2023
1 parent 3a0a048 commit 3dfd6aa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ edition = "2021"
anyhow = "1"
async-trait = "0"
aws-config = { version = "0" }
aws-credential-types = { version = "0" }
aws-sdk-kinesis = { version = "0" }
chrono = { version = "0", features = ["clock", "std"] }
clap = { version = "4", features = ["derive"] }
Expand Down
27 changes: 2 additions & 25 deletions src/kinesis/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use std::error::Error;
use std::io;
use std::sync::Arc;
use std::time::Duration;

use anyhow::Result;
use aws_credential_types::provider::error::CredentialsError;
use aws_sdk_kinesis::error::SdkError;
use aws_sdk_kinesis::operation::get_shard_iterator::{
GetShardIteratorError, GetShardIteratorOutput,
};
use aws_sdk_kinesis::operation::list_shards::{ListShardsError, ListShardsOutput};
use aws_sdk_kinesis::operation::list_shards::ListShardsOutput;
use chrono::Utc;
use log::{debug, info};
use tokio::sync::mpsc::Sender;
Expand Down Expand Up @@ -182,27 +179,7 @@ pub async fn get_shards(client: &AwsKinesisClient, stream: &str) -> io::Result<V

Ok(shards)
}
Err(e) => {
let message = match e.downcast_ref::<SdkError<ListShardsError>>() {
Some(SdkError::ServiceError(inner)) => inner.err().to_string(),
Some(SdkError::DispatchFailure(a)) => {
let credentials_errors = a
.as_connector_error()
.and_then(|e| e.source())
.and_then(|e| e.downcast_ref::<CredentialsError>())
.and_then(|e| e.source());

match credentials_errors {
Some(e) => e.to_string(),
_ => format!("DispatchFailure: {:?}", a),
}
}
Some(list_shards_errors) => format!("ListShardsError: {:?}", list_shards_errors),
other => format!("SdkError: {:?}", other),
};

Err(io::Error::new(io::ErrorKind::Other, message))
}
Err(e) => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", e))),
}
}

Expand Down

0 comments on commit 3dfd6aa

Please sign in to comment.