(error)
| 162 | |
| 163 | let deserialize; |
| 164 | function 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 | |
| 202 | module.exports = { serializeError, deserializeError }; |
no test coverage detected
searching dependent graphs…