I was wondering what the best approach to throwing errors from components. In the following example I check if there an action passed and I throw an error to prevent further execution this works, however the error route is not triggered as I would of expected.
/**
* Save step and go to the next step.
*/
next() {
if (isEmpty(this.get('nextAction'))) {
throw new Error('The nextAction is undefined.');
}
if (isEmpty(this.get('saveAction'))) {
throw new Error('The saveAction is undefined.');
}
const insuranceApplication = this.get('model');
if (this.isLastDependent(this.get('dependentIndex'), insuranceApplication.get('dependents.length'))) {
return this.get('nextAction')();
}
return this.get('saveAction')().then(() => {
this.set('dependent', this.getNextDependent(insuranceApplication.get('dependents')));
});
}
Aucun commentaire:
Enregistrer un commentaire