From 3dfd6aa6b9a81311ccbe0ea0b14332704067161d Mon Sep 17 00:00:00 2001 From: Romain Gallet Date: Fri, 20 Oct 2023 22:13:23 +0200 Subject: [PATCH] Credentials error reporting --- Cargo.lock | 1 - Cargo.toml | 1 - src/kinesis/helpers.rs | 27 ++------------------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f275fc5..8694fd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1032,7 +1032,6 @@ dependencies = [ "anyhow", "async-trait", "aws-config", - "aws-credential-types", "aws-sdk-kinesis", "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 395fe51..025d1e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } diff --git a/src/kinesis/helpers.rs b/src/kinesis/helpers.rs index 2bf093e..f5f697d 100644 --- a/src/kinesis/helpers.rs +++ b/src/kinesis/helpers.rs @@ -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; @@ -182,27 +179,7 @@ pub async fn get_shards(client: &AwsKinesisClient, stream: &str) -> io::Result { - let message = match e.downcast_ref::>() { - 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::()) - .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))), } }