Skip to content

Commit 919d142

Browse files
committed
chore: provide links to documentation for errors/warnings
closes #11305
1 parent c1c59e7 commit 919d142

File tree

15 files changed

+347
-371
lines changed

15 files changed

+347
-371
lines changed

.changeset/breezy-feet-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: provide links to documentation for errors/warnings

packages/svelte/scripts/process-messages/templates/client-errors.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import { DEV } from 'esm-env';
77
*/
88
export function CODE(PARAMETER) {
99
if (DEV) {
10-
const error = new Error(`${'CODE'}\n${MESSAGE}`);
10+
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
1111
error.name = 'Svelte error';
1212
throw error;
1313
} else {
14-
// TODO print a link to the documentation
15-
throw new Error('CODE');
14+
throw new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
1615
}
1716
}

packages/svelte/scripts/process-messages/templates/client-warnings.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ var normal = 'font-weight: normal';
99
*/
1010
export function CODE(PARAMETER) {
1111
if (DEV) {
12-
console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal);
12+
console.warn(
13+
`%c[svelte] ${'CODE'} (https://svelte.dev/e/${'CODE'})\n%c${MESSAGE}`,
14+
bold,
15+
normal
16+
);
1317
} else {
14-
// TODO print a link to the documentation
15-
console.warn('CODE');
18+
console.warn(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
1619
}
1720
}

packages/svelte/scripts/process-messages/templates/compile-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ function e(node, code, message) {
5656
* @returns {never}
5757
*/
5858
export function CODE(node, PARAMETER) {
59-
e(node, 'CODE', MESSAGE);
59+
e(node, `${'CODE'} (https://svelte.dev/e/${'CODE'})`, MESSAGE);
6060
}

packages/svelte/scripts/process-messages/templates/compile-warnings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ export const codes = CODES;
4747
* @param {string} PARAMETER
4848
*/
4949
export function CODE(node, PARAMETER) {
50-
w(node, 'CODE', MESSAGE);
50+
w(node, `${'CODE'} (https://svelte.dev/e/${'CODE'})`, MESSAGE);
5151
}

packages/svelte/scripts/process-messages/templates/server-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @returns {never}
55
*/
66
export function CODE(PARAMETER) {
7-
const error = new Error(`${'CODE'}\n${MESSAGE}`);
7+
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
88
error.name = 'Svelte error';
99
throw error;
1010
}

packages/svelte/scripts/process-messages/templates/shared-errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { DEV } from 'esm-env';
77
*/
88
export function CODE(PARAMETER) {
99
if (DEV) {
10-
const error = new Error(`${'CODE'}\n${MESSAGE}`);
10+
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
1111
error.name = 'Svelte error';
1212
throw error;
1313
} else {
1414
// TODO print a link to the documentation
15-
throw new Error('CODE');
15+
throw new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
1616
}
1717
}

packages/svelte/scripts/process-messages/templates/shared-warnings.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ var normal = 'font-weight: normal';
99
*/
1010
export function CODE(PARAMETER) {
1111
if (DEV) {
12-
console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal);
12+
console.warn(
13+
`%c[svelte] ${'CODE'} (https://svelte.dev/e/${'CODE'})\n%c${MESSAGE}`,
14+
bold,
15+
normal
16+
);
1317
} else {
1418
// TODO print a link to the documentation
15-
console.warn('CODE');
19+
console.warn(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
1620
}
1721
}

0 commit comments

Comments
 (0)