Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 1x 1x 1x 6x 3x 3x 3x 3x 4x 1x 1x 3x 3x 3x 3x 3x 1x 1x 1x 1x 8x 8x 1x 1x 2x 2x | import { Maybe } from "purify-ts"; export function ensureError(error: unknown): Error { if (error instanceof Error) return error; let stringified: string; try { stringified = JSON.stringify(error); } catch { stringified = "[Unable to stringify the thrown value]"; } return new Error( `This value was thrown as is, not through an Error: ${stringified}`, ); } const SECRET_REGEX = /(-\S*(?:key|token|pass)[^\s=]*(?:=| +))(\S*)/gi; export function hideSecrets(input: string) { return input.replace(SECRET_REGEX, "$1<secret value>"); } export function orThrow<T>(value: Maybe<T>, error: string): T { return value.toEither(new Error(error)).unsafeCoerce(); } |