GamendWeb.ErrorResponse (gamend_web v1.0.1216)

Copy Markdown View Source

Sends the real error page from a controller or a plug.

render_errors only catches errors that reach the endpoint as an exception — a route that never matched, or something that raised. Code which decides for itself that a request is a 404 and answers with text("Not Found") never goes near it, so a reader got nine bytes of plain text while the error template sat unused. That is what /ads did.

Rendering to a string rather than going through put_view keeps this usable from a plug, where there is no view or layout to configure, and guarantees the page is byte-identical to the one render_errors produces.

Summary

Functions

Replies 404 with the standard error page and halts.

Replies with the standard error page for status and halts.

Functions

not_found(conn)

@spec not_found(Plug.Conn.t()) :: Plug.Conn.t()

Replies 404 with the standard error page and halts.

Pass the conn through so the page picks up the reader's locale and theme.

send_error(conn, status)

@spec send_error(Plug.Conn.t(), pos_integer()) :: Plug.Conn.t()

Replies with the standard error page for status and halts.