Skip to content

CatchClause

A catch clause of a try statement.

import { CatchClause } from "@alloy-js/typescript";
<CatchClause parameter={ParameterDescriptor | string}>
{children}
</CatchClause>
childrenChildren
parameteroptionalParameterDescriptor | string

The parameter can be omitted for a catch-all clause, or provided as a string or ParameterDescriptor. When using a descriptor, a refkey can be provided to reference the parameter within the catch block. Note that TypeScript only allows any or unknown as catch parameter types.

<CatchClause parameter={{ name: "error", type: "unknown" }}>
console.error(error);
</CatchClause>

renders to

catch (error: unknown) {
console.error(error);
}