Skip to content

Configuration for ignoring specific exception types #520

Open
@jonatanklosko

Description

@jonatanklosko

Sometimes exceptions are expected. For example, Ecto.NoResultsError is raised when Repo.get! finds no result, but it implements the Plug.Exception protocol, and therefore is converted to a 404 response.

Currently the only way to ignore exceptions is adding expected: true field to the exception struct. However, this approach does not work when dealing with exceptions from other libraries, such as Ecto.NoResultsError, since we have no control over the struct.

One way to approach this would be to define a filter behaviour, the user would implement the behaviour by defining a module with a filter function, and then set that module via application config. For reference, here is an example from the Sentry Elixir integration. Another simpler approach would be to configure a list of ignored exceptions, but a behaviour gives the user more flexibility.

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