Description
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.