Updated editor error handler to work better with new API error messages

no issue
- pass a received API error directly through to the notifications service rather than adding an unnecessary prefix to the error message
This commit is contained in:
Kevin Ansfield 2019-03-12 17:49:15 +00:00
parent 9dc093939f
commit fc6574f0ed
2 changed files with 3 additions and 5 deletions

View File

@ -36,8 +36,6 @@ PostModel.eachAttribute(function (name) {
watchedProps.push(`post.${name}`);
});
// TODO: This has to be moved to the I18n localization file.
// This structure is supposed to be close to the i18n-localization which will be used soon.
const messageMap = {
errors: {
post: {
@ -52,7 +50,7 @@ const messageMap = {
scheduled: 'Scheduling failed'
},
scheduled: {
scheduled: 'Updated failed',
scheduled: 'Update failed',
draft: 'Unscheduling failed',
published: 'Publish failed'
}
@ -785,7 +783,7 @@ export default Controller.extend({
// TODO: remove this once validations are fixed
errorMessage = error[0];
} else if (error && error.payload && error.payload.errors && error.payload.errors[0].message) {
errorMessage = error.payload.errors[0].message;
return this.notifications.showAPIError(error, {key: 'post.save'});
} else {
errorMessage = 'Unknown Error';
}

View File

@ -454,7 +454,7 @@ describe('Acceptance: Editor', function () {
expect(
find('.gh-alert').textContent,
'alert text after failed schedule'
).to.match(/Saving failed: Error test/);
).to.match(/Error test/);
});
it('handles title validation errors correctly', async function () {