fix: cannot set property name of which has only a getter (#5574)

close #5572
This commit is contained in:
Zoltan Kochan
2022-11-02 10:36:42 +02:00
committed by GitHub
parent 5b509740e5
commit 14974d8029
2 changed files with 10 additions and 1 deletions

View File

@@ -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).

View File

@@ -11,7 +11,11 @@ export function errorHandler (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