MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / formatCause

Function formatCause

packages/plugins/onepassword/src/sdk/service.ts:55–65  ·  view source on GitHub ↗
(cause: unknown)

Source from the content-addressed store, hash-verified

53const SERVICE_ACCOUNT_TOKEN_RE = /ops_[A-Za-z0-9_-]+/g;
54
55const formatCause = (cause: unknown): string => {
56 // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: normalizing untyped op-js/SDK throwables into OnePasswordError.message
57 const maybeMessage = (cause as { readonly message?: unknown } | null | undefined)?.message;
58 const raw =
59 // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: last-resort stringification of a non-Error throwable
60 typeof maybeMessage === "string" && maybeMessage.length > 0 ? maybeMessage : String(cause);
61 return raw
62 .replace(SERVICE_ACCOUNT_TOKEN_RE, "[redacted 1Password token]")
63 .replace(/\s+/g, " ")
64 .trim();
65};
66
67const messageWithCause = (prefix: string, cause: unknown): string => {
68 const causeMessage = formatCause(cause);

Callers 1

messageWithCauseFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected