Skip to content
Closed
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
20 changes: 19 additions & 1 deletion packages/integrations/src/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,22 @@ export class Vue implements Integration {
*/
private readonly _attachProps: boolean = true;

/**
* When set to true, original Vue's `logError` will be called as well.
* https://github.com/vuejs/vue/blob/c2b1cfe9ccd08835f2d99f6ce60f67b4de55187f/src/core/util/error.js#L38-L48
*/
private readonly _logErrors: boolean = false;

/**
* @inheritDoc
*/
public constructor(options: { Vue?: any; attachProps?: boolean } = {}) {
public constructor(options: { Vue?: any; attachProps?: boolean; logErrors?: boolean } = {}) {
// tslint:disable-next-line: no-unsafe-any
this._Vue = options.Vue || getGlobalObject<any>().Vue;

if (options.logErrors !== undefined) {
this._logErrors = options.logErrors;
}
if (options.attachProps === false) {
this._attachProps = false;
}
Expand Down Expand Up @@ -99,6 +109,14 @@ export class Vue implements Integration {
if (typeof oldOnError === 'function') {
oldOnError.call(this._Vue, error, vm, info);
}

if (this._logErrors) {
if (process && process.env && process.env.NODE_ENV !== 'production') {
this._Vue.util.warn(`Error in ${info}: "${error.toString()}"`, vm);
}
// tslint:disable-next-line:no-console
console.error(error);
}
};
}
}