0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-04 02:01:58 -05:00

Improved displayed error message when editor reaches bad saving state

ref https://linear.app/tryghost/issue/ONC-323

- added explicit 404 handling to the editor's save task so we can display a more direct/useful error message
This commit is contained in:
Kevin Ansfield 2024-09-13 11:30:03 +01:00
parent f054205e58
commit a9bf6c66ed
2 changed files with 14 additions and 2 deletions

View file

@ -22,7 +22,7 @@ import {inject} from 'ghost-admin/decorators/inject';
import {isBlank} from '@ember/utils';
import {isArray as isEmberArray} from '@ember/array';
import {isHostLimitError, isServerUnreachableError, isVersionMismatchError} from 'ghost-admin/services/ajax';
import {isInvalidError} from 'ember-ajax/errors';
import {isInvalidError, isNotFoundError} from 'ember-ajax/errors';
import {mobiledocToLexical} from '@tryghost/kg-converters';
import {inject as service} from '@ember/service';
import {slugify} from '@tryghost/string';
@ -652,6 +652,17 @@ export default class LexicalEditorController extends Controller {
return;
}
// This shouldn't occur but we have a bug where a new post can get
// into a bad state where it's not saved but the store is treating
// it as saved and performing PUT requests with no id. We want to
// be noisy about this early to avoid data loss
if (isNotFoundError(error)) {
console.error(error); // eslint-disable-line no-console
Sentry.captureException(error, {tags: {savePostTask: true}});
this._showErrorAlert(prevStatus, this.post.status, 'Editor has crashed. Please copy your content and start a new post.');
return;
}
if (error && !isInvalidError(error)) {
console.error(error); // eslint-disable-line no-console
Sentry.captureException(error, {tags: {savePostTask: true}});

View file

@ -706,7 +706,8 @@ describe('Acceptance: Editor', function () {
await pasteInEditor('Testing');
// we should see an error - previously this was failing silently
expect(find('.gh-alert-content')).to.have.trimmed.text('Resource could not be found.');
// error message comes from editor's own handling rather than our generic API error fallback
expect(find('.gh-alert-content')).to.have.trimmed.text('Saving failed: Editor has crashed. Please copy your content and start a new post.');
});
});
});