From 6f0753f65aaa107aadf14e2ba2fa958ebbc5a140 Mon Sep 17 00:00:00 2001 From: Garrett Campbell Date: Tue, 13 Aug 2024 12:51:42 -0400 Subject: [PATCH] rollbar try catch --- src/rollbar.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rollbar.ts b/src/rollbar.ts index 08f662e192..0d947c61fa 100644 --- a/src/rollbar.ts +++ b/src/rollbar.ts @@ -6,6 +6,7 @@ import * as logging from './logging'; import * as nls from 'vscode-nls'; import * as path from 'path'; import { logEvent } from './telemetry'; +import * as lodash from "lodash"; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -76,7 +77,11 @@ class RollbarController { * @returns The LogResult if we are enabled. `null` otherwise. */ exception(what: string, exception: Error, additional: object = {}): void { - log.fatal(localize('unhandled.exception', 'Unhandled exception: {0}', what), exception, JSON.stringify(additional, (key, value) => stringifyReplacer(key, value))); + try { + log.fatal(localize('unhandled.exception', 'Unhandled exception: {0}', what), exception, JSON.stringify(additional, (key, value) => stringifyReplacer(key, value))); + } catch (e) { + log.fatal(localize('unhandled.exception', 'Unhandled exception: {0}', what), exception, lodash.toString(additional)); + } const callstack = cleanStack(exception.stack); const message = cleanString(exception.message); logEvent('exception2', { message, callstack });