Skip to main content

output.fail

Write a structured error to stderr and exit the process. Default exit code is 1.

Parameters

ParameterTypeDescription
codestringA machine-readable error code (e.g., "NOT_FOUND", "TIMEOUT")
messagestringA human-readable error description
exitCodenumberProcess exit code (default: 1)

Returns

never

Example

import { output } from "@hmcs/sdk/commands";

output.fail("NOT_FOUND", "Entity does not exist");
// stderr: {"code":"NOT_FOUND","message":"Entity does not exist"}\n
// process exits with code 1