We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Graceful Exception Handling in Phoenix Applications
297
clicks
Source: peterullrich.com
In the article, author Peter Ullrich addresses a common issue faced by Elixir developers using the Phoenix framework -- noisy exceptions that clutter log files and trigger unnecessary alerts. He specifically discusses exceptions like Phoenix.NotAcceptableError and Plug.CSRFProtection.InvalidCSRFTokenError that are thrown when invalid or potentially malicious requests are made to the application. Ullrich then presents a straightforward solution: implementing the Plug.Exception protocol to convert these exceptions into HTTP 400 Bad Request responses, which prevents the application from raising errors and alerting error trackers. He provides code examples demonstrating how to catch these exceptions and details how to write tests to ensure that the exceptions properly return HTTP 400 responses instead of raising errors. Ullrich concludes by mentioning his startup, Indie Courses, and inviting readers to follow him on social media and subscribe to his newsletter.
Related posts
© HashMerge 2024