Skip to content

Raise typed exceptions instead of bare Exception #310

Open

Description

@nielspardon

The builders, type inference, SQL frontend and derivation-expression code raise plain Exception in about 42 places. For example, "No matching overload for 'add' …" comes from type inference. Callers can't tell these failures apart from other errors without matching on the message.

Proposal: add a small hierarchy under a common base, e.g. SubstraitError(Exception) with subclasses such as FunctionResolutionError and SchemaError. Fit the existing DerivationExpressionParseError and UnrecognizedSubstraitTypeError into it. Use TypeError where ruff's TRY004 flags an isinstance check. Every new class still subclasses Exception, so existing except Exception handlers keep working.

When this is done, remove TRY002/TRY004 from lint.extend-ignore in pyproject.toml (added in #305).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions