# CatchClause

A catch clause of a try statement.

* jsx

  ```tsx
  import { CatchClause } from "@alloy-js/typescript";


  <CatchClause parameter={ParameterDescriptor | string}>
    {children}
  </CatchClause>
  ```

* stc

  ```ts
  import { CatchClause } from "@alloy-js/typescript/stc";


  CatchClause({ parameter: ParameterDescriptor | string }).children(children)
  ```

## Props

|           |                                                                           |   |
| --------- | ------------------------------------------------------------------------- | - |
| children  | [Children](../../../core/types/children/)                                 |   |
| parameter | optional[ParameterDescriptor](../../types/parameterdescriptor/) \| string |   |

## Remarks

The parameter can be omitted for a catch-all clause, or provided as a string or [ParameterDescriptor](../../types/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

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

renders to

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