MCPcopy Index your code
hub / github.com/nodejs/node / deserializeError

Function deserializeError

lib/internal/error_serdes.js:164–200  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

162
163let deserialize;
164function deserializeError(error) {
165 deserialize ??= require('v8').deserialize;
166 switch (error[0]) {
167 case kSerializedError: {
168 const { constructor, properties } = deserialize(error.subarray(1));
169 const ctor = errors[constructor];
170 ObjectDefineProperty(properties, SymbolToStringTag, {
171 __proto__: null,
172 value: { __proto__: null, value: 'Error', configurable: true },
173 enumerable: true,
174 });
175 if ('cause' in properties && 'value' in properties.cause) {
176 properties.cause.value = deserializeError(properties.cause.value);
177 }
178 return ObjectCreate(ctor.prototype, properties);
179 }
180 case kSerializedObject:
181 return deserialize(error.subarray(1));
182 case kInspectedError:
183 return fromBuffer(error).toString('utf8');
184 case kInspectedSymbol: {
185 const buf = fromBuffer(error);
186 return SymbolFor(StringPrototypeSubstring(buf.toString('utf8'), kSymbolStringLength, buf.length - 1));
187 }
188 case kCustomInspectedObject:
189 return {
190 __proto__: null,
191 [customInspectSymbol]: () => fromBuffer(error).toString('utf8'),
192 };
193 case kCircularReference:
194 return {
195 __proto__: null,
196 [customInspectSymbol]: () => '[Circular object]',
197 };
198 }
199 require('assert').fail('This should not happen');
200}
201
202module.exports = { serializeError, deserializeError };

Callers 4

[kOnErrorMessage]Method · 0.85
#unwrapMessageMethod · 0.85
#handleReportItemMethod · 0.85
cycleFunction · 0.85

Calls 5

fromBufferFunction · 0.85
requireFunction · 0.50
deserializeFunction · 0.50
toStringMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…