Skip to main content
Version: v0.0.3

Function: toCliError()

toCliError(err): CliError

Coerce an unknown thrown value into a CliError. A CliError passes through; anything else becomes a CLI_INTERNAL / EXIT.SOFTWARE error whose message is a fixed, value-free string: the original message is deliberately discarded so a parser exception that embedded input bytes can never reach stderr.

Parameters

err

unknown

The caught value.

Returns

CliError

A CliError safe to render to stderr.

Example

import { toCliError } from "@cosyte/cli";

toCliError(new Error("boom")).code; // => "CLI_INTERNAL"