aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/logger/err-serializer.ts
blob: f6381bb6322c576c406607088c137441787a3138 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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, // TODO #12874
        'https://**redacted**@',
      );
    }
  }
  return response;
}