# failure.upstream

A service we depend on failed or timed out: a feed, an email provider, an API

Profile: [Errors](https://www.prongs.dev/docs/intents/errors.md) · Raised with: [`fail()`](https://www.prongs.dev/docs/profiles/errors.md) · Status: `502` · Message: generic · Writes: [`incident.degraded`](https://www.prongs.dev/docs/intents/incident/degraded.md)

## Example

```ts
return fail('failure.upstream', 'Feed host timed out.', { cause: error });
```

The caller gets

```bash
HTTP 502

{
  "ok": false,
  "error": "A service we depend on isn’t responding. Try again.",
  "code": "failure.upstream"
}
```

And it writes incident.degraded

```ts
{
  "intent": "incident.degraded",
  "level": "warn",
  "alert": false,
  "message": "Feed host timed out.",
  "data": {
    "intent": "failure.upstream",
    "cause": {
      "name": "PostgresError",
      "message": "connection terminated unexpectedly",
      "stack": "PostgresError: connection terminated…"
    }
  },
  "time": "2026-10-09T12:00:00.000Z"
}
```

## Choosing between neighbours

Find the row that describes your case, and use the intent on the right.

| If it is for… | Use |
|---|---|
| A service we depend on failed or timed out: a feed, an email provider, an API | `failure.upstream` (this page) |

## Connections

Declared in the registry, both directions. Where an intent is used in your own code is something check and the gallery see; this site has no app code.

- Built from: [`status.badgateway`](https://www.prongs.dev/docs/intents/errors.md#status-badgateway)
- Writes: [`incident.degraded`](https://www.prongs.dev/docs/intents/incident/degraded.md)

## For registry authors

**Starter intents.** These are the intents `prongs add errors` puts in your registry, raised with [`fail()`](https://www.prongs.dev/docs/profiles/errors.md). Change the messages to suit your app, and the statuses through the [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) intents they are built from.

The entry `prongs add errors` writes into your registry. Change the message here, or the status through its [`status.*`](https://www.prongs.dev/docs/intents/errors.md#status) ref.

```ts
'failure.upstream': {
  kind: 'semantic',
  description: 'A service we depend on failed or timed out: a feed, an email provider, an API',
  refs: ['status.badgateway'],
  binding: {
    publicMessage: 'A service we depend on isn’t responding. Try again.',
    logs: 'incident.degraded',
  },
},
```
