# Errors

> Specify error types and schemas

In order to generate SDKs idiomatically, Fern needs to know how to differentiate
between different errors when parsing an endpoint response.

### Discriminate by status code

You can specify Fern to discriminate by status code. This means on each
endpoint, every error that's listed must have a different HTTP status code.

<CodeBlock title="api.yml">
  ```yaml
  name: api
  error-discrimination:
    strategy: status-code
  ```
</CodeBlock>

### Discriminate by error name

You can specify Fern to discriminate by error name. If you select this strategy,
then Fern will assume that every error response has an extra property denoting
the error name.

If you use Fern to generate server-side code, then this option provides
the most flexibility. Otherwise, you'll probably want to use the status code
discrimination strategy.

<CodeBlock title="api.yml">
  ```yaml
  name: api
  error-discrimination:
    strategy: property
    property-name: errorName
  ```
</CodeBlock>

### Global errors

You can import and list errors that will be thrown by every endpoint.

<CodeBlock title="api.yml">
  ```yaml
  imports:
    commons: commons.yml

  errors:
    - commons.NotFoundError
    - commons.BadRequestError
  ```
</CodeBlock>