Skip to content

Commit

Permalink
Better error message for url exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 committed Oct 13, 2023
1 parent 7c452c8 commit 2c9887a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/common/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand Down

0 comments on commit 2c9887a

Please sign in to comment.