From 2c9887a6424a4c81f68a06fdcf9ad200d1757c9c Mon Sep 17 00:00:00 2001 From: Jean Pierre Date: Fri, 13 Oct 2023 01:11:02 -0500 Subject: [PATCH] Better error message for url exception --- src/common/telemetry.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/telemetry.ts b/src/common/telemetry.ts index cb2bd33..1925a5f 100644 --- a/src/common/telemetry.ts +++ b/src/common/telemetry.ts @@ -64,9 +64,13 @@ export function createSegmentAnalyticsClient(settings: AnalyticsSettings, gitpod } -export function getErrorMetricsEndpoint(gitpodHost: string): string { - const serviceUrl = new URL(gitpodHost); - return `https://ide.${serviceUrl.hostname}/metrics-api/reportError`; +function getErrorMetricsEndpoint(gitpodHost: string): string { + try { + const serviceUrl = new URL(gitpodHost); + return `https://ide.${serviceUrl.hostname}/metrics-api/reportError`; + } catch { + throw new Error(`Invalid URL: ${gitpodHost}`); + } } export async function commonSendEventData(logService: ILogService, segmentClient: Analytics | undefined, machineId: string, eventName: string, data?: any): Promise {