Show error message from backend

This commit is contained in:
Fatih Acet 2019-01-07 16:23:53 +01:00
parent 45eabf921a
commit f1acd50515
No known key found for this signature in database
GPG key ID: E994FE39E29B7E11
2 changed files with 9 additions and 3 deletions

View file

@ -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);
}
});
},

View file

@ -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();