Skip to content

Commit

Permalink
fix: fix error reporting when using the store
Browse files Browse the repository at this point in the history
  • Loading branch information
gluxon committed Sep 2, 2023
1 parent 6f9bcdb commit 9485b9b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/default-reporter/src/reportError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'])}`
Expand All @@ -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): {
Expand Down

0 comments on commit 9485b9b

Please sign in to comment.