Skip to content

fix: Make sure that error is present before logging it in Vue #3183

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

Merged
merged 1 commit into from
Jan 21, 2021
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
2 changes: 1 addition & 1 deletion packages/integrations/src/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class Vue implements Integration {

if (this._options.logErrors) {
if (this._options.Vue.util) {
this._options.Vue.util.warn(`Error in ${info}: "${error.toString()}"`, vm);
this._options.Vue.util.warn(`Error in ${info}: "${error && error.toString()}"`, vm);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know Vue, but will there ever be info if there is no error? What about vm?

In any case, it might be nice to provide the user with the information that the error is null rather than just now showing anything. That way, they know it's not the reporting that's broken.

Suggested change
this._options.Vue.util.warn(`Error in ${info}: "${error && error.toString()}"`, vm);
this._options.Vue.util.warn(`Error in ${info}: "${error && error.toString() || 'null'}"`, vm);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in foo: null

Looks strange to me, why would there be a warning in the first place.

Copy link
Member

@lobsterkatie lobsterkatie Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worse than Error in foo:, though? The dangling colon feels wrong to me.

Maybe Error in foo: <null> is better?

}
// eslint-disable-next-line no-console
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class VueHelper {

if (this._options.logErrors) {
if (this._options.Vue.util) {
this._options.Vue.util.warn(`Error in ${info}: "${error.toString()}"`, vm);
this._options.Vue.util.warn(`Error in ${info}: "${error && error.toString()}"`, vm);
}
// eslint-disable-next-line no-console
console.error(error);
Expand Down