{"version":3,"file":"error.mjs","names":[],"sources":["../../../../../../../../../../node_modules/@vitest/utils/dist/error.js"],"sourcesContent":["import { format } from '@vitest/pretty-format';\nimport { printDiffOrStringify, getDefaultFormatOptions } from './diff.js';\nimport { serializeValue } from './serialize.js';\nimport 'tinyrainbow';\nimport './display.js';\nimport './helpers.js';\nimport './constants.js';\n\nfunction processError(_err, diffOptions, seen = new WeakSet()) {\n\tif (!_err || typeof _err !== \"object\") {\n\t\treturn { message: String(_err) };\n\t}\n\tconst err = _err;\n\tif (err.showDiff || err.showDiff === undefined && err.expected !== undefined && err.actual !== undefined) {\n\t\tconst options = {\n\t\t\t...diffOptions,\n\t\t\t...err.diffOptions\n\t\t};\n\t\terr.diff = printDiffOrStringify(err.actual, err.expected, options, err);\n\t\terr.expected = prettifyValue(err.expected, options);\n\t\terr.actual = prettifyValue(err.actual, options);\n\t}\n\t// some Error implementations may not allow rewriting cause\n\t// in most cases, the assignment will lead to \"err.cause = err.cause\"\n\ttry {\n\t\tif (!seen.has(err) && typeof err.cause === \"object\") {\n\t\t\tseen.add(err);\n\t\t\terr.cause = processError(err.cause, diffOptions, seen);\n\t\t}\n\t} catch {}\n\ttry {\n\t\treturn serializeValue(err);\n\t} catch (e) {\n\t\treturn serializeValue(new Error(`Failed to fully serialize error: ${e?.message}\\nInner error message: ${err?.message}`));\n\t}\n}\nfunction prettifyValue(value, options) {\n\tif (typeof value !== \"string\") {\n\t\treturn format(value, getDefaultFormatOptions(options));\n\t}\n\treturn value;\n}\n\nexport { processError, serializeValue as serializeError };\n"],"x_google_ignoreList":[0],"mappings":";;;;;AAQA,SAAS,aAAa,MAAM,aAAa,uBAAO,IAAI,QAAQ,GAAG;CAC9D,IAAI,CAAC,QAAQ,OAAO,SAAS,UAC5B,OAAO,EAAE,SAAS,OAAO,IAAI,EAAE;CAEhC,MAAM,MAAM;CACZ,IAAI,IAAI,YAAY,IAAI,aAAa,UAAa,IAAI,aAAa,UAAa,IAAI,WAAW,QAAW;EACzG,MAAM,UAAU;GACf,GAAG;GACH,GAAG,IAAI;EACR;EACA,IAAI,OAAO,qBAAqB,IAAI,QAAQ,IAAI,UAAU,SAAS,GAAG;EACtE,IAAI,WAAW,cAAc,IAAI,UAAU,OAAO;EAClD,IAAI,SAAS,cAAc,IAAI,QAAQ,OAAO;CAC/C;CAGA,IAAI;EACH,IAAI,CAAC,KAAK,IAAI,GAAG,KAAK,OAAO,IAAI,UAAU,UAAU;GACpD,KAAK,IAAI,GAAG;GACZ,IAAI,QAAQ,aAAa,IAAI,OAAO,aAAa,IAAI;EACtD;CACD,QAAQ,CAAC;CACT,IAAI;EACH,OAAO,eAAe,GAAG;CAC1B,SAAS,GAAG;EACX,OAAO,+BAAe,IAAI,MAAM,oCAAoC,GAAG,QAAQ,yBAAyB,KAAK,SAAS,CAAC;CACxH;AACD;AACA,SAAS,cAAc,OAAO,SAAS;CACtC,IAAI,OAAO,UAAU,UACpB,OAAO,OAAO,OAAO,wBAAwB,OAAO,CAAC;CAEtD,OAAO;AACR"}