Skip to content

Commit

Permalink
feat(errors): Show specific error for conversion failure (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickr authored and mergify[bot] committed Sep 3, 2019
1 parent d2deb4d commit effb263
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/RepStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class RepStatus extends EventEmitter {
case ERROR_CODE.CONVERSION_UNSUPPORTED_FORMAT:
errorMessage = __('error_bad_file');
break;
case ERROR_CODE.CONVERSION_FAILED:
errorMessage = __('error_reupload');
break;
default:
errorMessage = __('error_refresh');
break;
Expand Down
14 changes: 14 additions & 0 deletions src/lib/__tests__/RepStatus-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,20 @@ describe('lib/RepStatus', () => {
repStatus.handleResponse();
});

it('should reject with the re upload message if the rep status is error due to conversion failure', done => {
sandbox
.mock(repStatus)
.expects('reject')
.callsFake(err => {
expect(err.displayMessage).to.equal(__('error_reupload'));
done();
});
repStatus.representation.status.state = 'error';
repStatus.representation.status.code = 'error_conversion_failed';

repStatus.handleResponse();
});

it('should resolve if the rep status is success', () => {
sandbox.mock(repStatus).expects('resolve');
repStatus.representation.status.state = 'success';
Expand Down
1 change: 1 addition & 0 deletions src/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const ERROR_CODE = {
BROWSER_GENERIC: 'error_browser_generic',
BROWSER_UNSUPPORTED: 'error_browser_unsupported',
CONTENT_DOWNLOAD: 'error_content_download',
CONVERSION_FAILED: 'error_conversion_failed',
CONVERSION_GENERIC: 'error_conversion_generic',
CONVERSION_PASSWORD_PROTECTED: 'error_password_protected',
CONVERSION_TRY_AGAIN_LATER: 'error_try_again_later',
Expand Down

0 comments on commit effb263

Please sign in to comment.