Files
Brandon Cheng 831f574330 fix: propagate error cause when throwing PnpmError in @pnpm/npm-resolver (#10990)
* fix: show error cause when failing to read metadata

* fix: correct changeset package name and add cause assertion tests

- Fix changeset to reference @pnpm/resolving.npm-resolver (not @pnpm/npm-resolver)
- Add PnpmError cause unit tests in @pnpm/error
- Fix npm-resolver tests to actually verify cause on thrown errors
  (.toThrow() only checks message, not cause/hint/code properties)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 00:59:52 +01:00
..

@pnpm/error

An error class for pnpm errors

npm version

Installation

pnpm add @pnpm/error

Usage

import { PnpmError } from '@pnpm/error'

try {
    throw new PnpmError('THE_ERROR_CODE', 'The error message')
} catch (err: any) { // eslint-disable-line
    console.log(err.code)
    //> ERR_PNPM_THE_ERROR_CODE
    console.log(err.message)
    //> The error message
}

License

MIT