Skip to content

Commit b08a4b4

Browse files
committed
move error from client to shared
1 parent 2e656d3 commit b08a4b4

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

documentation/docs/98-reference/.generated/client-errors.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,3 @@ Reading state that was created inside the same derived is forbidden. Consider us
133133
```
134134
Updating state inside a derived or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
135135
```
136-
137-
### structured_clone_state_proxy
138-
139-
```
140-
To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`
141-
```

documentation/docs/98-reference/.generated/shared-errors.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ Certain lifecycle methods can only be used during component initialisation. To f
6060
`%name%` is not a store with a `subscribe` method
6161
```
6262

63+
### structured_clone_state_proxy
64+
65+
```
66+
To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`
67+
```
68+
6369
### svelte_element_invalid_this_value
6470

6571
```

packages/svelte/messages/client-errors/errors.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,3 @@ See the [migration guide](/docs/svelte/v5-migration-guide#Components-are-no-long
8787
## state_unsafe_mutation
8888

8989
> Updating state inside a derived or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
90-
91-
## structured_clone_state_proxy
92-
93-
> To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`

packages/svelte/messages/shared-errors/errors.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ Certain lifecycle methods can only be used during component initialisation. To f
5252

5353
> `%name%` is not a store with a `subscribe` method
5454
55+
## structured_clone_state_proxy
56+
57+
> To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`
58+
5559
## svelte_element_invalid_this_value
5660

5761
> The `this` prop on `<svelte:element>` must be a string, if defined

packages/svelte/src/internal/client/errors.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -335,19 +335,4 @@ export function state_unsafe_mutation() {
335335
} else {
336336
throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
337337
}
338-
}
339-
340-
/**
341-
* To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`
342-
* @returns {never}
343-
*/
344-
export function structured_clone_state_proxy() {
345-
if (DEV) {
346-
const error = new Error(`structured_clone_state_proxy\nTo correctly clone a \`$state\` proxy, use \`$state.snapshot\` instead of \`structuredClone\`\nhttps://svelte.dev/e/structured_clone_state_proxy`);
347-
348-
error.name = 'Svelte error';
349-
throw error;
350-
} else {
351-
throw new Error(`https://svelte.dev/e/structured_clone_state_proxy`);
352-
}
353338
}

packages/svelte/src/internal/shared/clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { DEV } from 'esm-env';
33
import { STATE_SYMBOL } from '../client/constants.js';
44
import * as w from './warnings.js';
5-
import * as e from '../client/errors.js';
5+
import * as e from './errors.js';
66
import {
77
get_prototype_of,
88
is_array,

packages/svelte/src/internal/shared/errors.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,19 @@ export function svelte_element_invalid_this_value() {
6262
} else {
6363
throw new Error(`https://svelte.dev/e/svelte_element_invalid_this_value`);
6464
}
65+
}
66+
67+
/**
68+
* To correctly clone a `$state` proxy, use `$state.snapshot` instead of `structuredClone`
69+
* @returns {never}
70+
*/
71+
export function structured_clone_state_proxy() {
72+
if (DEV) {
73+
const error = new Error(`structured_clone_state_proxy\nTo correctly clone a \`$state\` proxy, use \`$state.snapshot\` instead of \`structuredClone\`\nhttps://svelte.dev/e/structured_clone_state_proxy`);
74+
75+
error.name = 'Svelte error';
76+
throw error;
77+
} else {
78+
throw new Error(`https://svelte.dev/e/structured_clone_state_proxy`);
79+
}
6580
}

0 commit comments

Comments
 (0)