redactErrorCredentials
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
redactErrorCredentials<
E>(error,seen?):E
Defined in: src/util/RedactUrlCredentials.ts:683
A copy of error with redactUrlCredentials applied to everything a
subscriber can read off it — the message, the stack (V8 renders it as
Name: message followed by the frames, so the message is in there twice),
every own string-valued property, the cause chain, and the errors nested
inside an array property such as AggregateError.errors. Enumerability is
preserved per property, so the copy serialises the way the original does.
Why a copy and not an in-place scrub. The Error belongs to the driver
that threw it, which may still hold the reference and may have handed it to
other listeners of its own; rewriting message under them is a side effect
this project has no right to cause.
Why not a plain wrap either. Replacing the error with a fresh one loses
the type, and the type is what a monitor branches on — e.name,
e instanceof AmqpConnectionError, e.code === 'ECONNREFUSED'. So the copy
is made to answer those questions the same way the original does: it carries
the original’s prototype, so instanceof still holds, and its own
enumerable properties, so code / errno / syscall survive. What it
deliberately does not carry is anything reachable only through a getter —
a getter can recompute the secret, and a redaction that can be undone by
reading a property is not one. A DOMException is copied as one: its
name, message and code are getters over slots only its own
constructor fills, so a plain Error given its prototype throws on all
three — and fetch rejects with one whenever a request is aborted (found
while #1458).
A strict no-op where there is nothing to mask. An error whose message
and own data properties carry no scheme://…@ authority — the overwhelming
majority — comes back as itself, not as a copy: there is nothing a copy
could hide, and the original keeps its stack, its identity and everything
a copy could not carry. So does one whose cause and nested errors carry
none either.
seen breaks a cyclic cause chain; callers do not pass it.
Type Parameters
Section titled “Type Parameters”E extends Error
Parameters
Section titled “Parameters”E
Set<unknown> = ...
Returns
Section titled “Returns”E
