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.

api.yml
1name: api
2error-discrimination:
3 strategy: status-code

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.

api.yml
1name: api
2error-discrimination:
3 strategy: property
4 property-name: errorName

Global errors

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

api.yml
1imports:
2 commons: commons.yml
3
4errors:
5 - commons.NotFoundError
6 - commons.BadRequestError