@@ -26,6 +26,7 @@ interface PrintErrorOptions {
2626 logger: Logger
2727 fullStack?: boolean
2828 showCodeFrame?: boolean
29+ printProperties?: boolean
2930}
3031
3132interface PrintErrorResult {
@@ -57,7 +58,7 @@ export function printError(
5758 project: WorkspaceProject | undefined,
5859 options: PrintErrorOptions,
5960): PrintErrorResult | undefined {
60- const { showCodeFrame = true, fullStack = false, type } = options
61+ const { showCodeFrame = true, fullStack = false, type, printProperties = true } = options
6162 const logger = options.logger
6263 let e = error as ErrorWithDiff
6364
@@ -109,7 +110,9 @@ export function printError(
109110 }
110111 })
111112
112- const errorProperties = getErrorProperties(e)
113+ const errorProperties = printProperties
114+ ? getErrorProperties(e)
115+ : {}
113116
114117 if (type) {
115118 printErrorType(type, project.ctx)
@@ -350,14 +353,21 @@ export function printStack(
350353 if (stack.length) {
351354 logger.error()
352355 }
353- const hasProperties = Object.keys(errorProperties).length > 0
354- if (hasProperties) {
356+ if (hasProperties(errorProperties)) {
355357 logger.error(c.red(c.dim(divider())))
356358 const propertiesString = inspect(errorProperties)
357359 logger.error(c.red(c.bold('Serialized Error:')), c.gray(propertiesString))
358360 }
359361}
360362
363+ function hasProperties(obj: any) {
364+ // eslint-disable-next-line no-unreachable-loop
365+ for (const _key in obj) {
366+ return true
367+ }
368+ return false
369+ }
370+
361371export function generateCodeFrame(
362372 source: string,
363373 indent = 0,
0 commit comments