File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,9 @@ defmodule ErrorTrackerDev.Live do
156156 < li >
157157 < . link href = "/exception " > Generate an exception from the controller</ . link >
158158 </ li >
159+ < li >
160+ < . link href = "/plug_exception " > Generate an exception from the router</ . link >
161+ </ li >
159162 < li >
160163 < . link href = "/exit " > Generate an exit from the controller</ . link >
161164 </ li >
@@ -205,6 +208,8 @@ defmodule ErrorTrackerDev.Endpoint do
205208
206209 # Use a custom Content Security Policy
207210 plug :set_csp
211+ # Raise an exception in the /plug_exception path
212+ plug :plug_exception
208213 # Our custom router which allows us to have regular controllers and live views
209214 plug ErrorTrackerDev.Router
210215
@@ -220,6 +225,12 @@ defmodule ErrorTrackerDev.Endpoint do
220225 |> Plug.Conn . assign ( :custom_csp_nonce , "#{ nonce } " )
221226 |> Plug.Conn . put_resp_header ( "content-security-policy" , Enum . join ( policies , " " ) )
222227 end
228+
229+ defp plug_exception ( conn = % Plug.Conn { path_info: path_info } , _opts ) when is_list ( path_info ) do
230+ if "plug_exception" in path_info ,
231+ do: raise ( "Crashed in Endpoint" ) ,
232+ else: conn
233+ end
223234end
224235
225236defmodule ErrorTrackerDev.ErrorView do
You can’t perform that action at this time.
0 commit comments