Skip to content

Commit 8926cb7

Browse files
authored
fix(v8/vue): Re-throw error when no errorHandler exists (#14943)
PR for v9: #14958
1 parent 785aab3 commit 8926cb7

File tree

4 files changed

+126
-143
lines changed

4 files changed

+126
-143
lines changed

dev-packages/e2e-tests/test-applications/vue-3/tests/errors.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('sends an error', async ({ page }) => {
1919
type: 'Error',
2020
value: 'This is a Vue test error',
2121
mechanism: {
22-
type: 'generic',
22+
type: 'vue',
2323
handled: false,
2424
},
2525
},
@@ -47,7 +47,7 @@ test('sends an error with a parameterized transaction name', async ({ page }) =>
4747
type: 'Error',
4848
value: 'This is a Vue test error',
4949
mechanism: {
50-
type: 'generic',
50+
type: 'vue',
5151
handled: false,
5252
},
5353
},

packages/vue/src/errorhandler.ts

Lines changed: 10 additions & 4 deletions
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' },
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

Lines changed: 2 additions & 0 deletions
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)