Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle 'no route matched' in Ember.js and show 404 page?

Tags:

ember.js

How can I handle the error

Uncaught Error: No route matched the URL '...' 

and show a custom 404 page?


Note: This question was asked before and answered several months ago - but does not work anymore.

like image 640
stephanos Avatar asked Jan 27 '13 14:01

stephanos


1 Answers

App.Router.map(function() {   //set up all of your known routes, and then...   this.route("fourOhFour", { path: "*path"}); }); 

.. where you have your FourOhFourRoute defined to show the "no route found" message of your choosing. You will be able to access the originally requested path in the fourOhFour route as the path parameter.

EDIT: just for clarity -- this answer came after the others were reported not to work anymore.

EDIT 2: I've updated the answer to reflect Yehuda Katz's comment (if I have it wrong, please LMK).

like image 79
laurelnaiad Avatar answered Oct 05 '22 23:10

laurelnaiad