Throw exceptions and handle them locally and globally


Hi there,

I am currently building an app and I am wondering what would be the best approach to catches the errors locally and globally.

Example of a local error handling:

The user enters information into a form, would like to throw/send/notify that there is an error, and the locally-defined error handler catches it and displays the error on top of the form. This should be defined at the component or controller level I guess, but how? If it’s an unexpected error, it would bubble to the global error handler.

Example of a global error handling:

If the user upload an image and the image doesn’t match with the requirement, I would like to throw/send/notify that there is an error with the image to a globally defined error handler. Should this be defined in the app route? app controller? This error handler would then either log the error (for unexpected error), or display the expected error to the user in a modal, defined at the app level of the app.

If you have any example where you treat the errors that way, or if you think it should be treated in a different way, I would really like to have your opinion on this.




Not sure of your version ,but did you see the docs, specifically the section “The Error Event”? From my reading of that, the appropriate place would be to define a catch-all on the application level route, and then on various sub-routes as is applicable. Elsewhere there, you see (under ‘error substates’) that various routes that end in ‘error’ appear to be what Ember is looking for.