feat: make Exceptions public
Is your feature request related to a problem?
I have some code that looks like
from typing import Sized, Union
from ibis.common.exceptions import ExpressionError
from ibis.expr.types import Table
Sizable = Union[int, Sized, Table]
def get_len(x: Sizable) -> int:
if isinstance(x, int):
return x
try:
return len(x)
except (TypeError, ExpressionError):
return x.count().execute()
I would prefer to be able to access the exceptions directly, as ibis.ExpressionError. Then, you are free to move them around internally. ibis.errors or ibis.exceptions would also be reasonable public API exposure points. Or, these Exceptions should be documented so I know that importing them from ibis.common.exceptions is a stable API (but I still don't like the extra typing).
What version of ibis are you running?
main
What backend(s) are you using, if any?
NA
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@NickCrews Thanks for the issue!
We're going to rework some of the exceptions in the near feature to be more specific (NotSupportedByBackendError, TBD on naming 😄) and more consistently-used for the same kinds of errors in different places. Because of that I think we're a little reluctant to expose all existing exceptions right now.
@jcrist suggested adding an ibis.exceptions module that we slowly add things to that we feel confident are stable. Thoughts?
Yeah that sounds good!
xref #9695
Once the above PR is merged, we can add a top-level ibis.exceptions module and add TableNotFound as a start.