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

Report dev error at viewer channel timeout #25931

Merged
merged 2 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export function isUserErrorMessage(message) {
return message.indexOf(USER_ERROR_SENTINEL) >= 0;
}

/**
* @param {string} message
* @return {string} The new message without USER_ERROR_SENTINEL
*/
export function stripUserError(message) {
return message.replace(USER_ERROR_SENTINEL, '');
}

/**
* @param {string} message
* @return {boolean} Whether this message was a a user error from an iframe embed.
Expand Down
18 changes: 14 additions & 4 deletions src/service/viewer-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import {Observable} from '../observable';
import {Services} from '../services';
import {ViewerInterface} from './viewer-interface';
import {VisibilityState} from '../visibility-state';
import {dev, devAssert, duplicateErrorIfNecessary} from '../log';
import {
dev,
devAssert,
duplicateErrorIfNecessary,
stripUserError,
} from '../log';
import {findIndex} from '../utils/array';
import {
getSourceOrigin,
Expand Down Expand Up @@ -856,17 +861,22 @@ export class ViewerImpl {
}

/**
* Creates an error for the case where a channel cannot be established.
* Creates a dev error for the case where a channel cannot be established.
* @param {*=} opt_reason
* @return {!Error}
*/
function getChannelError(opt_reason) {
let channelError;
if (opt_reason instanceof Error) {
opt_reason = duplicateErrorIfNecessary(opt_reason);
opt_reason.message = 'No messaging channel: ' + opt_reason.message;
return opt_reason;
channelError = opt_reason;
} else {
channelError = new Error('No messaging channel: ' + opt_reason);
}
return new Error('No messaging channel: ' + opt_reason);
// Force convert user error to dev error
channelError.message = stripUserError(channelError.message);
return channelError;
}

/**
Expand Down