Skip to content

Commit ff923f9

Browse files
authored
ref(dsn): improve invalid dsn error message (#4430)
1 parent 3f2bf69 commit ff923f9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/utils/src/dsn.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function dsnFromString(str: string): DsnComponents {
3131
const match = DSN_REGEX.exec(str);
3232

3333
if (!match) {
34-
throw new SentryError('Invalid Dsn');
34+
throw new SentryError(`Invalid Sentry Dsn: ${str}`);
3535
}
3636

3737
const [protocol, publicKey, pass = '', host, port = '', lastPath] = match.slice(1);
@@ -82,20 +82,20 @@ function validateDsn(dsn: DsnComponents): boolean | void {
8282
const requiredComponents: ReadonlyArray<keyof DsnComponents> = ['protocol', 'publicKey', 'host', 'projectId'];
8383
requiredComponents.forEach(component => {
8484
if (!dsn[component]) {
85-
throw new SentryError(`Invalid Dsn: ${component} missing`);
85+
throw new SentryError(`Invalid Sentry Dsn: ${component} missing`);
8686
}
8787
});
8888

8989
if (!projectId.match(/^\d+$/)) {
90-
throw new SentryError(`Invalid Dsn: Invalid projectId ${projectId}`);
90+
throw new SentryError(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
9191
}
9292

9393
if (!isValidProtocol(protocol)) {
94-
throw new SentryError(`Invalid Dsn: Invalid protocol ${protocol}`);
94+
throw new SentryError(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
9595
}
9696

9797
if (port && isNaN(parseInt(port, 10))) {
98-
throw new SentryError(`Invalid Dsn: Invalid port ${port}`);
98+
throw new SentryError(`Invalid Sentry Dsn: Invalid port ${port}`);
9999
}
100100

101101
return true;

0 commit comments

Comments
 (0)