diff --git a/src/lib/RepStatus.js b/src/lib/RepStatus.js index 1315c0044a..f2ee731ecf 100644 --- a/src/lib/RepStatus.js +++ b/src/lib/RepStatus.js @@ -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; diff --git a/src/lib/__tests__/RepStatus-test.js b/src/lib/__tests__/RepStatus-test.js index 9fd2689f8e..1a84ecfb49 100644 --- a/src/lib/__tests__/RepStatus-test.js +++ b/src/lib/__tests__/RepStatus-test.js @@ -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'; diff --git a/src/lib/events.js b/src/lib/events.js index 75f4477f0f..b1960edeb8 100644 --- a/src/lib/events.js +++ b/src/lib/events.js @@ -18,33 +18,34 @@ export const VIEWER_EVENT = { // Error codes logged by preview with "preview_error" events export const ERROR_CODE = { ACCOUNT: 'error_account', - UNSUPPORTED_FILE_TYPE: 'error_unsupported_file_type', - PERMISSIONS_PREVIEW: 'error_permissions_preview', BAD_INPUT: 'error_bad_input', + 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', + CONVERSION_UNSUPPORTED_FORMAT: 'error_unsupported_format', DELETED_REPS: 'error_deleted_reps', + EXCEEDED_RETRY_LIMIT: 'error_exceeded_retry_limit', + FLASH_NOT_ENABLED: 'error_flash_not_enabled', + GENERIC: 'error_generic', + IMAGE_SIZING: 'error_image_sizing', + INVALID_CACHE_ATTEMPT: 'error_invalid_file_for_cache', LOAD_ANNOTATIONS: 'error_load_annotations', LOAD_ASSET: 'error_load_asset', LOAD_CSV: 'error_load_csv', LOAD_DOCUMENT: 'error_load_document', LOAD_MEDIA: 'error_load_media', LOAD_VIEWER: 'error_load_viewer', - IMAGE_SIZING: 'error_image_sizing', - SHAKA: 'error_shaka', - INVALID_CACHE_ATTEMPT: 'error_invalid_file_for_cache', + NOT_DOWNLOADABLE: 'error_file_not_downloadable', + PERMISSIONS_PREVIEW: 'error_permissions_preview', PREFETCH_FILE: 'error_prefetch_file', RATE_LIMIT: 'error_rate_limit', - EXCEEDED_RETRY_LIMIT: 'error_exceeded_retry_limit', - BROWSER_GENERIC: 'error_browser_generic', - BROWSER_UNSUPPORTED: 'error_browser_unsupported', - NOT_DOWNLOADABLE: 'error_file_not_downloadable', - GENERIC: 'error_generic', - CONVERSION_GENERIC: 'error_conversion_generic', - CONVERSION_PASSWORD_PROTECTED: 'error_password_protected', - CONVERSION_TRY_AGAIN_LATER: 'error_try_again_later', - CONVERSION_UNSUPPORTED_FORMAT: 'error_unsupported_format', + SHAKA: 'error_shaka', + UNSUPPORTED_FILE_TYPE: 'error_unsupported_file_type', VIEWER_LOAD_TIMEOUT: 'error_viewer_load_timeout', - CONTENT_DOWNLOAD: 'error_content_download', - FLASH_NOT_ENABLED: 'error_flash_not_enabled', }; // Event fired from Preview with error details