Last active
January 3, 2019 07:36
-
-
Save sgmurphy/5ef3b27a4e1de0f7fd86e5b1d463bd3e to your computer and use it in GitHub Desktop.
Ember error pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: config.locationType, | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
// app routes | |
// ... | |
this.route('403'); // 403 Forbidden | |
this.route('404', { path: '*path' }); // 404 Not Found | |
}); | |
export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
actions: { | |
error(error, transition) { | |
if (error.errors) { | |
switch (parseInt(error.errors[0].status)) { | |
case 401: | |
// Redirect to login page | |
this.transitionTo('login'); | |
return false; | |
case 403: | |
// Show forbidden error page | |
this.intermediateTransitionTo('403'); | |
return false; | |
case 404: | |
// Show page not found error page | |
this.intermediateTransitionTo('404', ''); | |
return false; | |
case 500: | |
// Log error and show default error page | |
return true; | |
} | |
} | |
return true; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment