Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent Annotations errors from triggering a Preview failure #904

Merged
merged 8 commits into from
Jan 29, 2019

Conversation

pramodsum
Copy link
Contributor

@pramodsum pramodsum commented Jan 25, 2019

  • Adds ability to emit silent preview errors without triggering the Preview error viewer. This is useful for cases such as annotations, where failures don't necessarily mean that the entire preview experience needs to fail

  • Update tests

- Adds ability to emit silent preview errors without triggering the Preview error viewer. This is useful for cases such as annotations, where failures don't necessarily mean that the entire preview experience needs to fail
@boxcla
Copy link

boxcla commented Jan 25, 2019

Verified that @pramodsum has signed the CLA. Thanks for the pull request!

@jeremypress
Copy link
Contributor

Why not just directly call this.emit('error', error) in the annotations error listener and not call triggerError?

@pramodsum
Copy link
Contributor Author

preview.triggerError() generates a more thorough log event which i figured might be useful to also have.

    /**
     * Create a generic log Object.
     *
     * @private
     * @return {Object} Log details for viewer session and current file.
     */
    createLogEvent() {
        const file = this.file || {};
        const log = {
            timestamp: getISOTime(),
            file_id: getProp(file, 'id', ''),
            file_version_id: getProp(file, 'file_version.id', ''),
            content_type: getProp(this.viewer, 'options.viewer.NAME', ''),
            extension: file.extension || '',
            locale: getProp(this.location, 'locale', ''),
            rep_type: getProp(this.viewer, 'options.representation.representation', '').toLowerCase(),
            ...getClientLogDetails()
        };

        return log;
    }

@jeremypress
Copy link
Contributor

This is what we do for silent preview errors in Preview.js

const err = new PreviewError(ERROR_CODE.INVALID_CACHE_ATTEMPT, message, { file });
this.emitPreviewError(err);

@pramodsum pramodsum merged commit 0db8b4b into box:master Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants