mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix: report correct errors when using the pnpm server (#7032)
This commit is contained in:
6
.changeset/wet-lies-smoke.md
Normal file
6
.changeset/wet-lies-smoke.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/default-reporter": patch
|
||||
pnpm: patch
|
||||
---
|
||||
|
||||
Fix a bug causing errors to be printed as `Cannot read properties of undefined (reading 'code')` instead of the underlying reason when using the pnpm store server.
|
||||
@@ -21,7 +21,7 @@ const colorPath = chalk.gray
|
||||
|
||||
export function reportError (logObj: Log, config?: Config) {
|
||||
const errorInfo = getErrorInfo(logObj, config)
|
||||
let output = formatErrorSummary(errorInfo.title, logObj['err']['code'])
|
||||
let output = formatErrorSummary(errorInfo.title, (logObj as LogObjWithPossibleError).err?.code)
|
||||
if (logObj['pkgsStack'] != null) {
|
||||
if (logObj['pkgsStack'].length > 0) {
|
||||
output += `\n\n${formatPkgsStack(logObj['pkgsStack'])}`
|
||||
@@ -33,6 +33,14 @@ export function reportError (logObj: Log, config?: Config) {
|
||||
output += `\n\n${errorInfo.body}`
|
||||
}
|
||||
return output
|
||||
|
||||
/**
|
||||
* A type to assist with introspection of the logObj.
|
||||
* These objects may or may not have an `err` field.
|
||||
*/
|
||||
interface LogObjWithPossibleError {
|
||||
readonly err?: { code?: string }
|
||||
}
|
||||
}
|
||||
|
||||
function getErrorInfo (logObj: Log, config?: Config): {
|
||||
|
||||
Reference in New Issue
Block a user