| 352 | } |
| 353 | |
| 354 | async #handleError (err) { |
| 355 | if (err) { |
| 356 | // Get the local package if it exists for a more helpful error message |
| 357 | const localPkg = await require('@npmcli/package-json') |
| 358 | .normalize(this.localPrefix) |
| 359 | .then(p => p.content) |
| 360 | .catch(() => null) |
| 361 | Object.assign(err, this.#getError(err, { pkg: localPkg })) |
| 362 | } |
| 363 | |
| 364 | this.finish(err) |
| 365 | |
| 366 | if (err) { |
| 367 | throw err |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | #getError (rawErr, opts) { |
| 372 | const { files = [], ...error } = require('./utils/error-message.js').getError(rawErr, { |