use iceberg::{Error, ErrorKind, NamespaceIdent, Result, TableIdent};
pub fn from_sqlx_error(error: sqlx::Error) -> Error {
Error::new(
ErrorKind::Unexpected,
"operation failed for hitting sqlx error".to_string(),
)
.with_source(error)
}
pub fn no_such_namespace_err<T>(namespace: &NamespaceIdent) -> Result<T> {
Err(Error::new(
ErrorKind::Unexpected,
format!("No such namespace: {namespace:?}"),
))
}
pub fn no_such_table_err<T>(table_ident: &TableIdent) -> Result<T> {
Err(Error::new(
ErrorKind::Unexpected,
format!("No such table: {table_ident:?}"),
))
}
pub fn table_already_exists_err<T>(table_ident: &TableIdent) -> Result<T> {
Err(Error::new(
ErrorKind::Unexpected,
format!("Table {table_ident:?} already exists."),
))
}