Files
klz-cables.com/.pnpm-store/v10/files/cd/43f2048433b680369aa224fa0c39c33919ada90833910408bf64d58f2a22facb47570d3eb44a90136760c7f2ba58b5e87112df53039d7f2cf43b8a80d43bd1
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

74 lines
2.3 KiB
Plaintext

'use strict'
module.exports = prettifyErrorLog
const {
LOGGER_KEYS
} = require('../constants')
const isObject = require('./is-object')
const joinLinesWithIndentation = require('./join-lines-with-indentation')
const prettifyObject = require('./prettify-object')
/**
* @typedef {object} PrettifyErrorLogParams
* @property {object} log The error log to prettify.
* @property {PrettyContext} context The context object built from parsing
* the options.
*/
/**
* Given a log object that has a `type: 'Error'` key, prettify the object and
* return the result. In other
*
* @param {PrettifyErrorLogParams} input
*
* @returns {string} A string that represents the prettified error log.
*/
function prettifyErrorLog ({ log, context }) {
const {
EOL: eol,
IDENT: ident,
errorProps: errorProperties,
messageKey
} = context
const stack = log.stack
const joinedLines = joinLinesWithIndentation({ input: stack, ident, eol })
let result = `${ident}${joinedLines}${eol}`
if (errorProperties.length > 0) {
const excludeProperties = LOGGER_KEYS.concat(messageKey, 'type', 'stack')
let propertiesToPrint
if (errorProperties[0] === '*') {
// Print all sibling properties except for the standard exclusions.
propertiesToPrint = Object.keys(log).filter(k => excludeProperties.includes(k) === false)
} else {
// Print only specified properties unless the property is a standard exclusion.
propertiesToPrint = errorProperties.filter(k => excludeProperties.includes(k) === false)
}
for (let i = 0; i < propertiesToPrint.length; i += 1) {
const key = propertiesToPrint[i]
if (key in log === false) continue
if (isObject(log[key])) {
// The nested object may have "logger" type keys but since they are not
// at the root level of the object being processed, we want to print them.
// Thus, we invoke with `excludeLoggerKeys: false`.
const prettifiedObject = prettifyObject({
log: log[key],
excludeLoggerKeys: false,
context: {
...context,
IDENT: ident + ident
}
})
result = `${result}${ident}${key}: {${eol}${prettifiedObject}${ident}}${eol}`
continue
}
result = `${result}${ident}${key}: ${log[key]}${eol}`
}
}
return result
}