---
url: https://scruple.dev/rules/api-contracts/no-ambiguous-failure-contracts.md
description: Disallow overlapping public failure channels.
---

# api-contracts/no-ambiguous-failure-contracts

Disallow overlapping public failure channels.

## What it checks

Directly exported functions should not mix nullable or sentinel results with thrown errors unless each failure representation has a visibly distinct role.

## Rule metadata

* Package: `@scruple/api-contracts`
* Category: API contracts
* Tags: failures, exports, return-values
* Default threshold: `0.8`
* Minimum confidence: `0.7`

## Examples

### Reported

```ts
export function findUser(id: string) { if (!id) throw new Error("missing"); return db.find(id) ?? null; }
```

### Accepted

```ts
export function findUser(id: string) { if (!id) return null; return db.find(id) ?? null; }
```
