Skip to content

Commit

Permalink
feat(archive): Catch random errors in BoxArchive and throw preview er…
Browse files Browse the repository at this point in the history
…ror (#1142)

* feat(archive): Catch random errors in BoxArchive and throw preview error

* feat(archive): Change error message

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Mingze and mergify[bot] committed Jan 7, 2020
1 parent 320a709 commit e83f0e8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib/viewers/archive/ArchiveViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import get from 'lodash/get';
import './Archive.scss';
import BaseViewer from '../BaseViewer';
import { VIEWER_EVENT } from '../../events';
import PreviewError from '../../PreviewError';
import { ERROR_CODE, VIEWER_EVENT } from '../../events';

const JS = ['archive.js'];
const CSS = ['archive.css'];
Expand Down Expand Up @@ -68,11 +69,12 @@ class ArchiveViewer extends BaseViewer {
return;
}

/*
global BoxArchive
The BoxArchive is loaded from archive.js
*/
this.archiveComponent = new BoxArchive(this.archiveEl, data);
try {
/* global BoxArchive loaded from archive.js */
this.archiveComponent = new BoxArchive(this.archiveEl, data);
} catch (error) {
throw new PreviewError(ERROR_CODE.LOAD_VIEWER, __('error_reupload'), error);
}

this.loaded = true;
this.emit(VIEWER_EVENT.load);
Expand Down

0 comments on commit e83f0e8

Please sign in to comment.