ibis icon indicating copy to clipboard operation
ibis copied to clipboard

feat: make Exceptions public

Open NickCrews opened this issue 2 years ago • 3 comments

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 avatar Aug 02 '23 20:08 NickCrews

@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?

cpcloud avatar Aug 04 '23 08:08 cpcloud

Yeah that sounds good!

NickCrews avatar Aug 04 '23 15:08 NickCrews

xref #9695

Once the above PR is merged, we can add a top-level ibis.exceptions module and add TableNotFound as a start.

gforsyth avatar Jul 31 '24 17:07 gforsyth