Skip to content

Commit

Permalink
fix: cannot set property name of which has only a getter (#5574)
Browse files Browse the repository at this point in the history
close #5572
  • Loading branch information
zkochan committed Nov 2, 2022
1 parent f8d77dc commit f61de1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wet-hornets-cheat.md
@@ -0,0 +1,5 @@
---
"pnpm": patch
---

Don't fail if cannot override the name field of the error object [#5572](https://github.com/pnpm/pnpm/issues/5572).
6 changes: 5 additions & 1 deletion packages/pnpm/src/err.ts
Expand Up @@ -11,7 +11,11 @@ export default function err (error: Error) {
return
}
if (error.name != null && error.name !== 'pnpm' && !error.name.startsWith('pnpm:')) {
error.name = 'pnpm'
try {
error.name = 'pnpm'
} catch {
// Sometimes the name property is read-only
}
}

// bole passes only the name, message and stack of an error
Expand Down

0 comments on commit f61de1d

Please sign in to comment.