errors.ts
This file
Path
src/utils/errors.ts
60 lines · 2.4 KiB · TypeScript
Last changed by
fix: Fixed security issue #738: prototype pollution possible when applying patches CVE-2020-28477Michel Weststratebefore adoptionda2bd4f
History of this fileTake it
The walk stopped after 200 commits: lines older than 949960f point at it.
fix: fixed broken minimized error url (issue#550)Michel Weststratebefore adoption949960f
lines 1–31why, one step back1const errors = {2 0: "Illegal state",3 1: "Immer drafts cannot have computed properties",4 2: "This object has been frozen and should not be mutated",5 3(data: any) {6 return (7 "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " +8 data9 )10 },11 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",12 5: "Immer forbids circular references",13 6: "The first or second argument to `produce` must be a function",14 7: "The third argument to `produce` must be a function or undefined",15 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object",16 9: "First argument to `finishDraft` must be a draft returned by `createDraft`",17 10: "The given draft is already finalized",18 11: "Object.defineProperty() cannot be used on an Immer draft",19 12: "Object.setPrototypeOf() cannot be used on an Immer draft",20 13: "Immer only supports deleting array indices",21 14: "Immer only supports setting array indices and the 'length' property",22 15(path: string) {23 return "Cannot apply patch, path doesn't resolve: " + path24 },25 16: 'Sets cannot have "replace" patches.',26 17(op: string) {27 return "Unsupported patch operation: " + op28 },29 18(plugin: string) {30 return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`31 },Immer 7Michel Weststratebefore adoption467ea5d
lines 32–34why, one step back32 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",33 21(thing: string) {34 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}'`Merge pull request #602 from immerjs/fix-600-isFrozenMichel Weststratebefore adoption8d4e0de
line 35why, one step back35 },Immer 7Michel Weststratebefore adoption467ea5d
lines 36–40why, one step back36 22(thing: string) {37 return `'current' expects a draft, got: ${thing}`38 },39 23(thing: string) {40 return `'original' expects a draft, got: ${thing}`fix: Fixed security issue #738: prototype pollution possible when applying patches CVE-2020-28477Michel Weststratebefore adoptionda2bd4f
lines 41–42why, one step back41 },42 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed"fix: fixed broken minimized error url (issue#550)Michel Weststratebefore adoption949960f
lines 43–56why, one step back43} as const4445export function die(error: keyof typeof errors, ...args: any[]): never {46 if (__DEV__) {47 const e = errors[error]48 const msg = !e49 ? "unknown error nr: " + error50 : typeof e === "function"51 ? e.apply(null, args as any)52 : e53 throw new Error(`[Immer] ${msg}`)54 }55 throw new Error(56 `[Immer] minified error nr: ${error}${chore: Merge branch 'master' of github.com:immerjs/immerMichel Weststratebefore adoption6c62eec
line 57why, one step back57 args.length ? " " + args.map(s => `'${s}'`).join(",") : ""fix: fixed broken minimized error url (issue#550)Michel Weststratebefore adoption949960f
lines 58–60why, one step back58 }. Find the full error at: https://bit.ly/3cXEKWf`59 )60}