Commit f1acd505 authored by Fatih Acet's avatar Fatih Acet

Show error message from backend

parent 45eabf92
...@@ -250,8 +250,14 @@ export default { ...@@ -250,8 +250,14 @@ export default {
if (error && error.name === 'SpamError') { if (error && error.name === 'SpamError') {
this.openRecaptcha(); this.openRecaptcha();
} else { } 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'); eventHub.$emit('close.form');
window.Flash(`Error updating ${this.issuableType}`); window.Flash(errMsg);
} }
}); });
}, },
......
...@@ -292,8 +292,8 @@ describe('Issuable output', () => { ...@@ -292,8 +292,8 @@ describe('Issuable output', () => {
it('shows error mesage from backend if exists', done => { it('shows error mesage from backend if exists', done => {
const msg = 'Custom error message from backend'; const msg = 'Custom error message from backend';
spyOn(vm.service, 'updateIssuable').and.callFake(() => spyOn(vm.service, 'updateIssuable').and.callFake(
Promise.reject({ response: { data: { errors: msg } } }), // eslint-disable-line prefer-promise-reject-errors () => Promise.reject({ response: { data: { errors: msg } } }), // eslint-disable-line prefer-promise-reject-errors
); );
vm.updateIssuable(); vm.updateIssuable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment