Skip to content

Commit b4abb07

Browse files
committed
fix(vue): Re-throw error when no errorHandler exists
1 parent 74e2982 commit b4abb07

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/vue/src/errorhandler.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ export const attachErrorHandler = (app: Vue, options: VueOptions): void => {
3030
setTimeout(() => {
3131
captureException(error, {
3232
captureContext: { contexts: { vue: metadata } },
33-
mechanism: { handled: false },
33+
mechanism: { handled: !!originalErrorHandler, type: 'vue-errorHandler' },
3434
});
3535
});
3636

3737
// Check if the current `app.config.errorHandler` is explicitly set by the user before calling it.
3838
if (typeof originalErrorHandler === 'function' && app.config.errorHandler) {
3939
(originalErrorHandler as UnknownFunc).call(app, error, vm, lifecycleHook);
40-
}
41-
42-
if (options.logErrors) {
40+
} // TODO(v9): Always throw when no user-defined error handler is provided (this will log the error to the console as well). Delete the Code with logErrors below
41+
/* else {
42+
throw error;
43+
} */
44+
45+
if (!originalErrorHandler) {
46+
throw error;
47+
// eslint-disable-next-line deprecation/deprecation
48+
} else if (options.logErrors) {
4349
const hasConsole = typeof console !== 'undefined';
4450
const message = `Error in ${lifecycleHook}: "${error && error.toString()}"`;
4551

packages/vue/src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export interface VueOptions {
4444
/**
4545
* When set to `true`, original Vue's `logError` will be called as well.
4646
* https://github.com/vuejs/vue/blob/c2b1cfe9ccd08835f2d99f6ce60f67b4de55187f/src/core/util/error.js#L38-L48
47+
*
48+
* @deprecated Will be removed in future versions of the SDK. The error will always be logged unless you define a custom Vue errorHandler.
4749
*/
4850
logErrors: boolean;
4951

0 commit comments

Comments
 (0)