throw { badCombo: 'Invalid email or username.' }
.intercept('incorrect', 'badCombo')
Hi,
How can I send the parameter with intercept, as with throw?
throw { badCombo: 'Invalid email or username.' }
.intercept('incorrect', 'badCombo')
Hi,
How can I send the parameter with intercept, as with throw?
.intercept()will accept two parameters
.intercept(filter, handler)
or just the handler
.intercept(handler)
to intercept all errors.
Handler here is the function which can either throw or simply use res object to respond with the error.
So one option to achieve desired result will be:
.intercept('incorrect', () => res.serverError({ badCombo: 'Invalid email or username.' });
Replace serverError with badRequest depending on your intent.
Another option would be to simply throw your error in the handler:
.intercept('incorrect', () => {
throw { badCombo: 'Invalid email or username.' };
};