dwyl / dwyl/learn-phoenix

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

Open
#65 0 comments 2 reactions 0 assignees View on GitHub
discuss enhancement question technical
Dominant language
No language data
Stars
664
Forks
41
PR merge metrics
No merged PRs in 30d

Description

> 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](https://cloud.githubusercontent.com/assets/194400/24142837/bbca255c-0e1f-11e7-8c6a-56f67015e884.png)

## Required

We need a way to create a "catch all" route that:
+ Timestamp the failed request occured
+ Logs the `url` the person was attempting to view
+ Logs any `conn` details e.g:
+ Device/Browser
+ Session ID (_so we can **help** the person if they were looking for something!_)
+ Any other _useful_ data?

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.