* Invoke an onerror callback. If the callback itself throws synchronously * or returns a promise that rejects, a SuppressedError wrapping both the * onerror failure and the original error is surfaced as an uncaught exception. * @param {Function} fn The onerror callback. * @param {any} error
(fn, error)
| 1200 | * @param {any} error The original error that triggered destruction. |
| 1201 | */ |
| 1202 | function invokeOnerror(fn, error) { |
| 1203 | try { |
| 1204 | const result = fn(error); |
| 1205 | if (isPromise(result)) { |
| 1206 | PromisePrototypeThen(result, undefined, (err) => { |
| 1207 | process.nextTick(() => { |
| 1208 | // eslint-disable-next-line no-restricted-syntax |
| 1209 | throw new SuppressedError(err, error, err?.message); |
| 1210 | }); |
| 1211 | }); |
| 1212 | } |
| 1213 | } catch (err) { |
| 1214 | process.nextTick(() => { |
| 1215 | // eslint-disable-next-line no-restricted-syntax |
| 1216 | throw new SuppressedError(err, error, err?.message); |
| 1217 | }); |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | function validateBody(body) { |
| 1222 | if (body === undefined) return body; |