Skip to content

Commit 6681898

Browse files
author
Jan Kaul
committed
make get_table_metadata_location_error transparent
1 parent 035d7a7 commit 6681898

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

catalogs/iceberg-s3tables-catalog/src/error.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use aws_sdk_s3tables::{
44
operation::{
55
create_namespace::CreateNamespaceError, create_table::CreateTableError,
66
delete_table::DeleteTableError, get_table::GetTableError,
7+
get_table_metadata_location::GetTableMetadataLocationError,
78
list_namespaces::ListNamespacesError, list_tables::ListTablesError,
89
update_table_metadata_location::UpdateTableMetadataLocationError,
910
},
@@ -26,7 +27,11 @@ pub enum Error {
2627
#[error(transparent)]
2728
GetTable(#[from] SdkError<GetTableError, HttpResponse>),
2829
#[error(transparent)]
29-
DeletaTable(#[from] SdkError<DeleteTableError, HttpResponse>),
30+
DeleteTable(#[from] SdkError<DeleteTableError, HttpResponse>),
31+
#[error(transparent)]
32+
SdkError(#[from] SdkError<GetTableMetadataLocationError, HttpResponse>),
33+
#[error(transparent)]
34+
GetTableMetadataLocation(#[from] GetTableMetadataLocationError),
3035
#[error(transparent)]
3136
CreateTable(#[from] SdkError<CreateTableError, HttpResponse>),
3237
#[error(transparent)]

catalogs/iceberg-s3tables-catalog/src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use std::{
66
use async_trait::async_trait;
77
use aws_config::SdkConfig;
88

9-
use aws_sdk_s3tables::{types::OpenTableFormat, Client};
9+
use aws_sdk_s3tables::{
10+
error::SdkError, operation::get_table_metadata_location::GetTableMetadataLocationError,
11+
types::OpenTableFormat, Client,
12+
};
1013
use iceberg_rust::{
1114
catalog::{
1215
commit::{
@@ -236,7 +239,15 @@ impl Catalog for S3TablesCatalog {
236239
.name(identifier.name())
237240
.send()
238241
.await
239-
.map_err(|_| IcebergError::CatalogNotFound)?;
242+
.map_err(|err| match err {
243+
SdkError::ServiceError(err) => match err.into_err() {
244+
GetTableMetadataLocationError::NotFoundException(_) => {
245+
IcebergError::CatalogNotFound
246+
}
247+
x => Error::from(x).into(),
248+
},
249+
x => Error::from(x).into(),
250+
})?;
240251

241252
let metadata_location = table.metadata_location.ok_or(Error::Text(format!(
242253
"Table {} not found.",

0 commit comments

Comments
 (0)