Skip to content

Commit 2c9887a

Browse files
committed
Better error message for url exception
1 parent 7c452c8 commit 2c9887a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/common/telemetry.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ export function createSegmentAnalyticsClient(settings: AnalyticsSettings, gitpod
6464
}
6565

6666

67-
export function getErrorMetricsEndpoint(gitpodHost: string): string {
68-
const serviceUrl = new URL(gitpodHost);
69-
return `https://ide.${serviceUrl.hostname}/metrics-api/reportError`;
67+
function getErrorMetricsEndpoint(gitpodHost: string): string {
68+
try {
69+
const serviceUrl = new URL(gitpodHost);
70+
return `https://ide.${serviceUrl.hostname}/metrics-api/reportError`;
71+
} catch {
72+
throw new Error(`Invalid URL: ${gitpodHost}`);
73+
}
7074
}
7175

7276
export async function commonSendEventData(logService: ILogService, segmentClient: Analytics | undefined, machineId: string, eventName: string, data?: any): Promise<void> {

0 commit comments

Comments
 (0)