Skip to main content

Type Definitions

StdinParseError

Error thrown by input.parse() when stdin is empty, contains invalid JSON, or fails Zod schema validation. The code field identifies the failure stage:

CodeMeaning
EMPTY_STDINNo input received on stdin
INVALID_JSONStdin content is not valid JSON
VALIDATION_ERRORJSON does not match the Zod schema (the details field contains the ZodError instance)
import { input, output, StdinParseError } from "@hmcs/sdk/commands";

try {
const data = await input.parse(schema);
output.succeed(await processData(data));
} catch (err) {
if (err instanceof StdinParseError) {
output.fail(err.code, err.message);
}
throw err;
}