Show error message from backend
This commit is contained in:
parent
45eabf921a
commit
f1acd50515
2 changed files with 9 additions and 3 deletions
|
@ -250,8 +250,14 @@ export default {
|
|||
if (error && error.name === 'SpamError') {
|
||||
this.openRecaptcha();
|
||||
} else {
|
||||
let errMsg = `Error updating ${this.issuableType}`;
|
||||
|
||||
if (error && error.response && error.response.data && error.response.data.errors) {
|
||||
errMsg = error.response.data.errors;
|
||||
}
|
||||
|
||||
eventHub.$emit('close.form');
|
||||
window.Flash(`Error updating ${this.issuableType}`);
|
||||
window.Flash(errMsg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -292,8 +292,8 @@ describe('Issuable output', () => {
|
|||
|
||||
it('shows error mesage from backend if exists', done => {
|
||||
const msg = 'Custom error message from backend';
|
||||
spyOn(vm.service, 'updateIssuable').and.callFake(() =>
|
||||
Promise.reject({ response: { data: { errors: msg } } }), // eslint-disable-line prefer-promise-reject-errors
|
||||
spyOn(vm.service, 'updateIssuable').and.callFake(
|
||||
() => Promise.reject({ response: { data: { errors: msg } } }), // eslint-disable-line prefer-promise-reject-errors
|
||||
);
|
||||
|
||||
vm.updateIssuable();
|
||||
|
|
Loading…
Reference in a new issue