0
votes

I'm building an elixir/phoenix project and want to do some additional handling for all uncaught errors including controller, view, router and socket communication errors.

What I want to do is that catch all uncaught errors and send error information to the external error log aggregator and re-raise the error again to go through original error process.

What would be the best option for me for example with following options? :

  • use Plug.ErrorHandler
  • use a Custom Plug
  • implement a Instrumenter

Thank you in advance.

1
Vote to close--very broad question that's asking for opinions. Maybe you could narrow the question a bit.Onorio Catenacci
You could check Sentry library for Elixir for some examples how others did this.Hauleth

1 Answers

2
votes

This question is very opinion-based, but I’d try to do my best to provide the least biased answer.

Phoenix itself uses a custom module, namely Plug.Debugger for almost that purpose in dev environment. Most of it’s functionality is providing the feedback, and it seems all you need from there is a custom call/2 wrapper.

The aforementioned functionality is exactly what is provided by Plug.ErrorHandler so I honestly do not see any reason to reinvent a wheel.