This addon will help you build better “404 Not Found” and other error pages in Ember.js.
Take a look at our demo page to better understand what this does!
Note
ember-error-route was written and is maintained by Mainmatter and contributors. We offer consulting, training, and team augmentation for Ember.js – check out our website to learn more!
- Ember.js v3.20 or above
- Ember CLI v3.20 or above
- Node.js v12 or above
ember install ember-error-route
-
Add an
error
route (this.route('error', { path: '*path' });
) to theapp/router.js
file -
Add the
error
route implementation:
import ErrorRoute from 'ember-error-route';
export default class CatchAllRoute extends ErrorRoute {}
- Wrap your
model()
hooks withtry/catch
and redirect the user to theerror
route:
@service router;
async model(params, transition) {
try {
return await fetch(`https://movies.com/${params.id}.json`);
} catch (error) {
this.router.replaceWith('error', { transition, error, title: 'Movie not found' });
}
}
See the Contributing guide for details.
This project is licensed under the MIT License.