What is the right approach of catch block inside the model() hook in emberjs

Am I allowed to add a catch method in my model hook? i.e. something like this:

model(params) { return this.store.findRecord(‘shop’, params.slug).catch(() => this.transitionTo(‘welcome.shops.index’)) },

My goal is to route the user whenever he entered the incorrect slug. If there is a better approach to my desire behaviour please suggest it. Would appreciate any help, thanks.

Heya! Since there’s a number of promises that could reject when entering a route including the one from the model hook, you might want to try using the Route’s error event.

(The docs in that link provide a decent example of what that would look like!)

Thank you @Spencer_Price for your suggestions. Will definitely try those approach.