We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Adds custom 404 and 500 error pages to your Phoenix application with proper templates and error handling. Replaces Phoenix's default error pages with branded, user-friendly versions that maintain consistency with your application's design.
Key Benefits
Implementation Details
The feature installs custom HTML templates for 404 and 500 errors, enabling the embed_templates
functionality in your ErrorHTML
controller. It creates a dedicated Fallback
exception module for LiveView error handling and updates existing tests to use regex matching instead of exact string comparison for more flexible error page testing.
Usage Example
# In a LiveView when a resource is not found
defmodule MyAppWeb.PostLive do
def mount(%{"id" => id}, _session, socket) do
case Posts.get_post(id) do
nil -> raise MyAppWeb.Fallback
post -> {:ok, assign(socket, :post, post)}
end
end
end
Configuration
No additional configuration required. The feature automatically generates responsive error templates with proper internationalization support using gettext/1
and maintains your existing Phoenix pipeline structure.