gcpreston / cuberacer_live

🧩 Twisty puzzle racing platform
https://cuberacer.io
0 stars 0 forks source link

Consolidate error pages #104

Open gcpreston opened 2 years ago

gcpreston commented 2 years ago

The code

conn
|> put_view(CuberacerLiveWeb.ErrorView)
|> put_status(status_code)
|> render("#{status_code}.html")

renders a 404 page, stylized with layout. I believe this is because it is a "successful" render from the route, which plugs the layout via the router. However, if a 404 occurs because of Ecto.NoResultsError, the Not Found message is rendered without the layout.

The documentation states that this is to avoid circular issues for things like errors while rendering the layout. However, this should be able to be mitigated because Cuberacer's layout is stable.

Investigate any errors that could cause an error render, ensure that the layout can't generate any, then render the layout with these error pages (relevant forum thread)