Skip to main content
Version: v0.0.3

Function: errorResult()

errorResult(err): RunResult

Resolve a CliError into a value-free RunResult: empty stdout (nothing reaches the data channel on an error), the rendered diagnostic on stderr, and the error's exit code. The single place the CLI turns an owned error into a result, so every command and the dispatcher render errors identically.

Parameters

err

CliError

The CLI error to resolve.

Returns

RunResult

The value-free RunResult.

Example

import { CliError, CLI_CODES, EXIT, errorResult } from "@cosyte/cli";

errorResult(new CliError(CLI_CODES.CLI_USAGE, EXIT.USAGE, "missing <file>")).exit; // => 2