My ErrovView
defmodule MyApp.ErrorView do
use MyApp.Web, :view
def render("404.json", _assigns) do
"Page not found - my custom json handler"
end
However, when I call a route which doesn’t exist:
curl -H "Content-Type: application/json" -X GET http://localhost:4000/some_random_route123
config:
config :my_app, MyApp.Endpoint,
render_errors: [view: MyApp.ErrorView, accepts: ~w(html json)],
it returns a long html page with an exception and all the details. Why not just a string “Page not found - my custom json handler”?
And how can I handle all such requests to non existing routes?