Skip to content

Commit

Permalink
chore: provide links to documentation for errors/warnings
Browse files Browse the repository at this point in the history
closes #11305
  • Loading branch information
dummdidumm committed Dec 9, 2024
1 parent c1c59e7 commit 919d142
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 371 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-feet-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: provide links to documentation for errors/warnings
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import { DEV } from 'esm-env';
*/
export function CODE(PARAMETER) {
if (DEV) {
const error = new Error(`${'CODE'}\n${MESSAGE}`);
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
error.name = 'Svelte error';
throw error;
} else {
// TODO print a link to the documentation
throw new Error('CODE');
throw new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ var normal = 'font-weight: normal';
*/
export function CODE(PARAMETER) {
if (DEV) {
console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal);
console.warn(
`%c[svelte] ${'CODE'} (https://svelte.dev/e/${'CODE'})\n%c${MESSAGE}`,
bold,
normal
);
} else {
// TODO print a link to the documentation
console.warn('CODE');
console.warn(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ function e(node, code, message) {
* @returns {never}
*/
export function CODE(node, PARAMETER) {
e(node, 'CODE', MESSAGE);
e(node, `${'CODE'} (https://svelte.dev/e/${'CODE'})`, MESSAGE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ export const codes = CODES;
* @param {string} PARAMETER
*/
export function CODE(node, PARAMETER) {
w(node, 'CODE', MESSAGE);
w(node, `${'CODE'} (https://svelte.dev/e/${'CODE'})`, MESSAGE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @returns {never}
*/
export function CODE(PARAMETER) {
const error = new Error(`${'CODE'}\n${MESSAGE}`);
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
error.name = 'Svelte error';
throw error;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { DEV } from 'esm-env';
*/
export function CODE(PARAMETER) {
if (DEV) {
const error = new Error(`${'CODE'}\n${MESSAGE}`);
const error = new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})\n${MESSAGE}`);
error.name = 'Svelte error';
throw error;
} else {
// TODO print a link to the documentation
throw new Error('CODE');
throw new Error(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ var normal = 'font-weight: normal';
*/
export function CODE(PARAMETER) {
if (DEV) {
console.warn(`%c[svelte] ${'CODE'}\n%c${MESSAGE}`, bold, normal);
console.warn(
`%c[svelte] ${'CODE'} (https://svelte.dev/e/${'CODE'})\n%c${MESSAGE}`,
bold,
normal
);
} else {
// TODO print a link to the documentation
console.warn('CODE');
console.warn(`${'CODE'} (https://svelte.dev/e/${'CODE'})`);
}
}
Loading

0 comments on commit 919d142

Please sign in to comment.