Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
imor committed Dec 11, 2024
1 parent e0742b6 commit 3df23e8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pg_replicate/src/clients/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl DeltaClient {
Ok(true)
} else {
Err(DeltaTableError::Generic(
"Storage type should start with either s3:// or file://".to_string(),
"storage type should start with either s3:// or file://".to_string(),
))
}
}
Expand Down Expand Up @@ -72,8 +72,8 @@ impl DeltaClient {

async fn try_open_delta_table(uri: &str) -> Result<DeltaTable, DeltaTableError> {
match Self::open_delta_table(uri).await? {
Some(tbl) => Ok(tbl),
None => Err(DeltaTableError::Generic("Table not found".to_string())),
Some(table) => Ok(table),
None => Err(DeltaTableError::Generic(format!("table `{uri}` not found"))),
}
}

Expand Down Expand Up @@ -207,7 +207,7 @@ impl DeltaClient {

if batches.is_empty() {
return Err(DeltaTableError::Generic(
"No data returned from the query".to_string(),
"failed to get last_lsn".to_string(),
));
}

Expand All @@ -218,12 +218,12 @@ impl DeltaClient {
.as_any()
.downcast_ref::<Int32Array>()
.ok_or_else(|| {
DeltaTableError::Generic("Failed to downcast column to Int64Array".to_string())
DeltaTableError::Generic("failed to downcast column to Int32Array".to_string())
})?;

if array.is_empty() {
return Err(DeltaTableError::Generic(
"No data in the 'lsn' column".to_string(),
"no data in the 'lsn' column".to_string(),
));
}
let lsn_value = array.value(0);
Expand Down Expand Up @@ -296,19 +296,19 @@ impl DeltaClient {
self.table_schemas
.as_ref()
.ok_or_else(|| {
DeltaTableError::Generic("Table schemas are not initialized".to_string())
DeltaTableError::Generic("table schemas are not initialized".to_string())
})?
.get(&table_id)
.ok_or_else(|| {
DeltaTableError::Generic(format!("Table schema not found for ID: {:?}", table_id))
DeltaTableError::Generic(format!("table schema not found for id: {:?}", table_id))
})
}

fn get_delta_schema(&self, table_name: &str) -> Result<&Arc<Schema>, DeltaTableError> {
self.delta_schemas
.as_ref()
.ok_or_else(|| {
DeltaTableError::Generic("Delta schemas are not initialized".to_string())
DeltaTableError::Generic("delta schemas are not initialized".to_string())
})?
.get(table_name)
.ok_or_else(|| DeltaTableError::NoSchema)
Expand Down

0 comments on commit 3df23e8

Please sign in to comment.