Suppress production errors

Hello All,

How do I ensure that crash dumps/errors in production are not sent to users?

In other languages such as Ruby or Rails, once the application is deployed and its environment set to production, errors are suppressed. The errors can be seen in the web server logs, but they’re not sent to the user. Instead, the user sees such responses like Internal server error, but the actual lines where the error occurred etc are not sent out to the user.

Any help will be much appreciated.

Regards,

Jerry

In my experience with Phoenix in production, the behavior you desire is the default behavior. Are you observing something else?

It works exactly the same in Phoenix.

The configuration I think that you are looking for is :debug_errors. That should only be set to true in local development (Endpoint configuration docs Phoenix.Endpoint — Phoenix v1.6.10)

Hope that helps!

1 Like

I am building APIs with Elixir Plugs. I have not done any development in Phoenix as yet.

Thank you.

In that case we’d need to see some code and the error that the app is showing to help you out. Are you using Plug.Debugger in your app?

Yes, I am using Plug.Debugger

Did you try the approach from the docs?

if Mix.env == :dev do
  use Plug.Debugger, otp_app: :my_app
end

No, I didn’t.
I only required it at the top of the code.

Kindly let me try it out.

Thanks so much for the pointers.

I shall feedback on the outcome.

Kind regards,
Jerry

1 Like