Closed cdesch closed 5 years ago
Hey @cdesch, since you are able to customize this with handle_errors
like you showed, I'm inclined to not have this in the library. Having this as a configuration option might limit the flexibility of filtering errors and I don't have a good API in mind. With handle_errors
, you're able to customize exactly how you need it for your application. Thanks a lot for the feature request! 💟
@whatyouhide Sounds good. I was thinking that it might be useful for not Phoenix applications, but I agreed in that handle_errors
is a good alternative. Thank you.
Just for anyone coming here by googling: an alternative for matching on reason.__struct__
is to do pattern matching on the handle_errors/2
function:
def handle_errors(_conn, %{reason: %Phoenix.Router.NoRouteError{}}), do: :ok
def handle_errors(conn, %{kind: kind, reason: reason, stack: stacktrace}) do
# Actual reporting logic
end
This avoids having to add a case
statement inside the handle_errors/2
function itself.
I want to add a filter for certain exception messages that can be put into the
config.exs
for Rollbax. I was thinking of something similar to the Rails Rollbar gem using a map like this:We would have to add an
:ignore
message type and check for it before reporting. If this is something folks want, I'd be willing to work on a PR, although I'd want some feedback on where to implement best prior to starting work.It could be handled in the
router
if you are using plug as described here in the docs. Here is my code in some simple filtering using plug. I think we would do something similar if the error structs were stored in theconfig.exs
although the error struct would be checked for reportable exception type when callingreport
,report_message
, orreport_exception