renovate/lib/logger/err-serializer.ts
Michael Kriese e4c1e042b8
fix(logger): handle errors (#7554)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2020-10-26 13:58:28 +01:00

21 lines
566 B
TypeScript

import is from '@sindresorhus/is';
import prepareError from './utils';
Error.stackTraceLimit = 20;
export default function errSerializer(err: Error): any {
const response: Record<string, unknown> = prepareError(err);
// already done by `sanitizeValue` ?
const redactedFields = ['message', 'stack', 'stdout', 'stderr'];
for (const field of redactedFields) {
const val = response[field];
if (is.string(val)) {
response[field] = val.replace(
/https:\/\/[^@]*?@/g,
'https://**redacted**@'
);
}
}
return response;
}