dwyl / learn-phoenix

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
649 stars 45 forks source link

How to create a "catch all" route for all 404 (not found) requests in Phoenix? #65

Open nelsonic opened 7 years ago

nelsonic commented 7 years ago

As a person using "the app" I want to see a friendly error message when I navigate to a "page" (route) that doesn't exisit. So that I don't feel like I "broke" something or worse that the app is "broken"...!

image

Required

We need a way to create a "catch all" route that:

Once we have logged the request we should show a friendly error page. We've done something similar before for Hapi.js: https://github.com/dwyl/hapi-error But we can take it much further now because we can assume that most Phoenix web apps will have a an Ecto Repo (i.e: a Database) where we can log the failed requests... could this be a perfect candidate for logging to ElasticSearch so we don't "pollute" the main DB? see: https://github.com/dwyl/learn-phoenix-framework/issues/64