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 fileTake it
The walk stopped after 200 commits: lines older than ba24aab 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 back1import {isFunction} from "../internal"2Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 3–6why, one step back3export 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 back7 function (plugin: string) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 8–9why, one step back8 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 back10 function (thing: string) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 11–13why, one step back11 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 back14 function (data: any) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 15–25why, one step back15 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 back26 function (thing: string) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 27–32why, one step back27 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 back33 function (thing: string) {Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 34–37why, one step back34 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 errorschore: Merge branch 'unional-prettier'Michel Weststratebefore adoption37eaf8f
line 38why, one step back38 ]Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 39why, one step back39 : []chore: Fix typo (#954)Marc Barbeaubefore adoptionba24aab
line 40why, one step back40Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
lines 41–42why, one step back41export function die(error: number, ...args: any[]): never {42 if (process.env.NODE_ENV !== "production") {chore: Fix typo (#954)Marc Barbeaubefore adoptionba24aab
line 43why, one step back43 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 back44 const msg = isFunction(e) ? e.apply(null, args as any) : echore: Fix typo (#954)Marc Barbeaubefore adoptionba24aab
lines 45–47why, one step back45 throw new Error(`[Immer] ${msg}`)46 }47 throw new Error(Merge pull request #1028 from immerjs/immer-10Michel Weststratebefore adoption2ef9a42
line 48why, one step back48 `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`chore: Fix typo (#954)Marc Barbeaubefore adoptionba24aab
lines 49–50why, one step back49 )50}