Skip to content
Myr

errors.ts

This file

Path

src/utils/errors.ts

50 lines · 2.2 KiB · TypeScript

Last changed by

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

History of this file

Take it

The walk stopped after 200 commits: lines older than 26355d7 point at it.

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

lines 1–2why, one step back
1import {isFunction} from "../internal"
2

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 3–6why, one step back
3export const errors =
4 process.env.NODE_ENV !== "production"5 ? [6 // All error codes, starting by 0:

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 7why, one step back
7 function (plugin: string) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 8–9why, one step back
8 return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`
9 },

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 10why, one step back
10 function (thing: string) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 11–13why, one step back
11 return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`
12 },13 "This object has been frozen and should not be mutated",

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 14why, one step back
14 function (data: any) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 15–25why, one step back
15 return (
16 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +17 data18 )19 },20 "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",21 "Immer forbids circular references",22 "The first or second argument to `produce` must be a function",23 "The third argument to `produce` must be a function or undefined",24 "First argument to `createDraft` must be a plain object, an array, or an immerable object",25 "First argument to `finishDraft` must be a draft returned by `createDraft`",

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 26why, one step back
26 function (thing: string) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 27–32why, one step back
27 return `'current' expects a draft, got: ${thing}`
28 },29 "Object.defineProperty() cannot be used on an Immer draft",30 "Object.setPrototypeOf() cannot be used on an Immer draft",31 "Immer only supports deleting array indices",32 "Immer only supports setting array indices and the 'length' property",

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 33why, one step back
33 function (thing: string) {

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 34–37why, one step back
34 return `'original' expects a draft, got: ${thing}`
35 }36 // Note: if more errors are added, the errorOffset in Patches.ts should be increased37 // See Patches.ts for additional errors

chore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f

line 38why, one step back
38 ]

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 39why, one step back
39 : []

chore: typo (#857)Kim Chanbefore adoption26355d7

line 40why, one step back
40

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

lines 41–42why, one step back
41export function die(error: number, ...args: any[]): never {
42 if (process.env.NODE_ENV !== "production") {

chore: typo (#857)Kim Chanbefore adoption26355d7

line 43why, one step back
43 const e = errors[error]

perf: Rewrite finalization system to use a callback approach instead of tree traversal (#1183)Mark Eriksonbefore adoptiond6c1202

line 44why, one step back
44 const msg = isFunction(e) ? e.apply(null, args as any) : e

chore: typo (#857)Kim Chanbefore adoption26355d7

lines 45–47why, one step back
45 throw new Error(`[Immer] ${msg}`)
46 }47 throw new Error(

Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42

line 48why, one step back
48 `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`

chore: typo (#857)Kim Chanbefore adoption26355d7

lines 49–50why, one step back
49 )
50}