@@ -55,13 +55,19 @@ defmodule ErrorTrackerDevWeb.PageController do
5555 content ( conn , """
5656 <h2>ErrorTracker Dev Server</h2>
5757 <div><a href="/errors">Open ErrorTracker</a></div>
58- <div><a href="/404">Generate 404 Error</a></div>
58+ <div><a href="/plug-exception">Generate Plug exception</a></div>
59+ <div><a href="/404">Generate Router 404</a></div>
60+ <div><a href="/noroute">Raise NoRouteError from a controller</a></div>
5961 <div><a href="/exception">Generate Exception</a></div>
6062 """ )
6163 end
6264
65+ def call ( conn , :noroute ) do
66+ raise Phoenix.Router.NoRouteError , conn: conn , router: ErrorTrackerDevWeb.Router
67+ end
68+
6369 def call ( _conn , :exception ) do
64- raise "This is an error "
70+ raise "This is a controller exception "
6571 end
6672
6773 defp content ( conn , content ) do
@@ -71,9 +77,18 @@ defmodule ErrorTrackerDevWeb.PageController do
7177 end
7278end
7379
80+ defmodule ErrorTrackerDevWeb.ErrorView do
81+ def render ( "404.html" , _assigns ) do
82+ "This is a 404"
83+ end
84+
85+ def render ( "500.html" , _assigns ) do
86+ "This is a 500"
87+ end
88+ end
89+
7490defmodule ErrorTrackerDevWeb.Router do
7591 use Phoenix.Router
76- use ErrorTracker.Integrations.Plug
7792
7893 pipeline :browser do
7994 plug :fetch_session
@@ -83,12 +98,14 @@ defmodule ErrorTrackerDevWeb.Router do
8398 scope "/" do
8499 pipe_through :browser
85100 get "/" , ErrorTrackerDevWeb.PageController , :index
101+ get "/noroute" , ErrorTrackerDevWeb.PageController , :noroute
86102 get "/exception" , ErrorTrackerDevWeb.PageController , :exception
87103 end
88104end
89105
90106defmodule ErrorTrackerDevWeb.Endpoint do
91107 use Phoenix.Endpoint , otp_app: :error_tracker
108+ use ErrorTracker.Integrations.Plug
92109
93110 @ session_options [
94111 store: :cookie ,
@@ -107,7 +124,11 @@ defmodule ErrorTrackerDevWeb.Endpoint do
107124
108125 plug Plug.RequestId
109126 plug Plug.Telemetry , event_prefix: [ :phoenix , :endpoint ]
127+ plug :maybe_exception
110128 plug ErrorTrackerDevWeb.Router
129+
130+ def maybe_exception ( % Plug.Conn { path_info: [ "plug-exception" ] } , _ ) , do: raise ( "Plug exception" )
131+ def maybe_exception ( conn , _ ) , do: conn
111132end
112133
113134defmodule Migration0 do
0 commit comments