CatchClause
A catch clause of a try statement.
import { CatchClause } from "@alloy-js/typescript";
<CatchClause parameter={ParameterDescriptor | string}> {children}</CatchClause>import { CatchClause } from "@alloy-js/typescript/stc";
CatchClause({ parameter: ParameterDescriptor | string }).children(children)| children | Children |
| parameter | optionalParameterDescriptor | string |
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”<CatchClause parameter={{ name: "error", type: "unknown" }}> console.error(error);</CatchClause>renders to
catch (error: unknown) { console.error(error);}