1) How can I handle "server error" and "page not found" on the application level? Where should I put a handler which renders appropriate pages?
That is, if a user goes to "my_website.com/fdafdsafds" -- how can I render the page "error/my_custom_404_page.html" to him?
Or if somewhere in my app an error occurs such as "1 / 0", how can I catch it on the application level?
2) Inside a plug I have this:
def call(conn, opts) do
if !some_condition do
# ....
else
# how to render an html template?
Conn.send_resp(conn, 401, "access denied") |> Conn.halt()
end
end
How can I render my custom error html template from "error/my_html_template.html" and pass parameters to it?