-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more variants to ErrorKind
#1038
Comments
Thanks @connortsui20 for raising this. I think the motivation behind is that when we add an |
Adding a separate error type for the catalog doesn't make it easier for users; instead, it adds more work on their end. At this stage, I think it would be good to have |
Sorry I should have been clear, I meant that there could be a dedicated Catalog error kind that could be a variant of pub enum ErrorKind {
Unexpected,
Catalog(CatalogErrorKind),
DataInvalid,
FeatureUnsupported,
}
pub enum CatalogErrorKind {
NoSuchNamespace,
NoSuchTable,
NamespaceAlreadyExists,
TableAlreadyExists,
} There's also potentially a And once table update is implemented, there should be |
I agree with @connortsui20 's idea. The current possible enums for ErrorKind is too bare, I think a |
I think this is an interesting problem to discuss. |
I'll circle back to one of the ideas I brought up: using And as a side note, I think that the current methodology of constructing an empty |
Before continuing the discussion, I would like to first explain our current error design goals. In general, error design needs to serve the following objectives:
Iceberg's error provides a clear This design shifts our focus from ourselves to our end users. We generally do not return errors like I still think it would be better if we had I propose to add: pub enum ErrorKind {
Unexpected,
DataInvalid,
FeatureUnsupported,
+ NamespaceNotFound,
+ NamespaceExists,
+ TableNotFound,
+ TableExists,
}
Hi, a dedicated catalog error kind doesn't look good to me. Let's try write code from our users side: let table = match ctl.load_table("test").await {
Ok(table) => table,
Err(err) if err.kind() == ErrorKind::TableNotExists => {
// handle table not exists, like gerenate a user-friendly error message
}
Err(err) => {
// unexpected things happend, we need to log or return bacl.
}
} If we have different layers of error kind: let table = match ctl.load_table("test").await {
Ok(table) => table,
Err(err) if err.kind() == ErrorKind::Catalog(CatalogErrorKind::NoSuchTable) => {
// handle table not exists, like gerenate a user-friendly error message
}
Err(err) => {
// unexpected things happend, we need to log or return bacl.
}
} Users need to be aware that it's a catalog error first. However, it's not something they need to take action on. Add more errors variants doesn't serve our error handling goal too. |
Is your feature request related to a problem or challenge?
As of now,
ErrorKind
looks like this (doc comments removed):This is pretty bare, especially since there are whole classes of things that can go wrong with respect to the Iceberg
Catalog
trait. See #965 and this comment for some context for this specific repo, as well as the official REST API specification.It would be nice if there was a dedicated error type for
Catalog
errors. Some simple things that could be added are variants for tables or namespaces that don't exist, or duplicate tables or namespaces. There are many other things that can go wrong. Right now #965 just uses string messages to represent those errors, which is not ideal.Adding dedicated error types would also mean the different implementations of the Iceberg Catalog could be more easily unified: the exact return behavior of each method would be the same among every implementation (instead of having a different error message depending on which implementation you choose).
Describe the solution you'd like
I think there are many ways to do this, some better than others. I would say that the current method manually implementing error messages, backtrace, and variants is somewhat shaky. Personally, I think that adding
thiserror
orsnafu
as a dependency for this would ease development going forward, not just the error types specified above (for the catalog) but for any other error kinds that Iceberg needs / may introduce.Willingness to contribute
The text was updated successfully, but these errors were encountered: