add error code

pull/16266/head
Rich Harris 3 months ago
parent c6b475c50a
commit a1250edbd5

@ -74,6 +74,12 @@ Effect cannot be created inside a `$derived` value that was not itself created i
Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
``` ```
### get_abort_signal_outside_reaction
```
`getAbortSignal()` can only be called inside an effect or derived
```
### hydration_failed ### hydration_failed
``` ```

@ -48,6 +48,10 @@ See the [migration guide](/docs/svelte/v5-migration-guide#Components-are-no-long
> Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops > Maximum update depth exceeded. This can happen when a reactive block or effect repeatedly sets a new value. Svelte limits the number of nested updates to prevent infinite loops
## get_abort_signal_outside_reaction
> `getAbortSignal()` can only be called inside an effect or derived
## hydration_failed ## hydration_failed
> Failed to hydrate the application > Failed to hydrate the application

@ -69,7 +69,7 @@ if (DEV) {
*/ */
export function getAbortSignal() { export function getAbortSignal() {
if (active_reaction === null) { if (active_reaction === null) {
throw new Error('TODO getAbortSignal can only be called inside a reaction'); e.get_abort_signal_outside_reaction();
} }
return (active_reaction.ac ??= new AbortController()).signal; return (active_reaction.ac ??= new AbortController()).signal;

@ -342,3 +342,19 @@ export function state_unsafe_mutation() {
throw new Error(`https://svelte.dev/e/state_unsafe_mutation`); throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
} }
} }
/**
* `getAbortSignal()` can only be called inside an effect or derived
* @returns {never}
*/
export function get_abort_signal_outside_reaction() {
if (DEV) {
const error = new Error(`get_abort_signal_outside_reaction\n\`getAbortSignal()\` can only be called inside an effect or derived\nhttps://svelte.dev/e/get_abort_signal_outside_reaction`);
error.name = 'Svelte error';
throw error;
} else {
throw new Error(`https://svelte.dev/e/get_abort_signal_outside_reaction`);
}
}
Loading…
Cancel
Save