@@ -57,6 +57,26 @@ defmodule ErrorTrackerDev.Controller do
5757 </ ul >
5858 """
5959 end
60+
61+ def noroute ( conn , _params ) do
62+ ErrorTracker . add_breadcrumb ( "ErrorTrackerDev.Controller.noroute/2" )
63+
64+ raise Phoenix.Router.NoRouteError , conn: conn , router: ErrorTrackerDev.Router
65+ end
66+
67+ def exception ( _conn , _params ) do
68+ ErrorTracker . add_breadcrumb ( "ErrorTrackerDev.Controller.exception/2" )
69+
70+ raise ErrorTrackerDev.Exception ,
71+ message: "This is a controller exception" ,
72+ bread_crumbs: [ "First" , "Second" ]
73+ end
74+
75+ def exit ( _conn , _params ) do
76+ ErrorTracker . add_breadcrumb ( "ErrorTrackerDev.Controller.exit/2" )
77+
78+ exit ( :timeout )
79+ end
6080end
6181
6282defmodule ErrorTrackerDev.Live do
@@ -127,7 +147,19 @@ defmodule ErrorTrackerDev.Live do
127147 </ li >
128148 </ ul >
129149
130- < h2 > Controller example</ h2 >
150+ < h2 > Controller examples</ h2 >
151+
152+ < ul >
153+ < li >
154+ < . link href = "/noroute " > Generate a 404 error from the controller</ . link >
155+ </ li >
156+ < li >
157+ < . link href = "/exception " > Generate an exception from the controller</ . link >
158+ </ li >
159+ < li >
160+ < . link href = "/exit " > Generate an exit from the controller</ . link >
161+ </ li >
162+ </ ul >
131163 """
132164 end
133165end
@@ -148,6 +180,9 @@ defmodule ErrorTrackerDev.Router do
148180 pipe_through :browser
149181
150182 live "/" , ErrorTrackerDev.Live
183+ get "/noroute" , ErrorTrackerDev.Controller , :noroute
184+ get "/exception" , ErrorTrackerDev.Controller , :exception
185+ get "/exit" , ErrorTrackerDev.Controller , :exit
151186
152187 scope "/dev" do
153188 error_tracker_dashboard "/errors"
@@ -156,8 +191,10 @@ defmodule ErrorTrackerDev.Router do
156191end
157192
158193defmodule ErrorTrackerDev.Endpoint do
159- # Default PhoenixPlayground.Endpoint
160194 use Phoenix.Endpoint , otp_app: :phoenix_playground
195+ use ErrorTracker.Integrations.Plug
196+
197+ # Default PhoenixPlayground.Endpoint
161198 plug Plug.Logger
162199 socket "/live" , Phoenix.LiveView.Socket
163200 plug Plug.Static , from: { :phoenix , "priv/static" } , at: "/assets/phoenix"
@@ -170,6 +207,16 @@ defmodule ErrorTrackerDev.Endpoint do
170207 plug ErrorTrackerDev.Router
171208end
172209
210+ defmodule ErrorTrackerDev.ErrorView do
211+ def render ( "404.html" , _assigns ) do
212+ "This is a 404"
213+ end
214+
215+ def render ( "500.html" , _assigns ) do
216+ "This is a 500"
217+ end
218+ end
219+
173220defmodule ErrorTrackerDev.GenServer do
174221 use GenServer
175222
@@ -193,6 +240,10 @@ defmodule ErrorTrackerDev.GenServer do
193240 end
194241end
195242
243+ defmodule ErrorTrackerDev.Exception do
244+ defexception [ :message , :bread_crumbs ]
245+ end
246+
196247PhoenixPlayground . start (
197248 endpoint: ErrorTrackerDev.Endpoint ,
198249 child_specs: [
0 commit comments