# Class APIError

API Error thrown when European Parliament API requests fail.

When thrown from BaseEPClient's HTTP layer, the message always includes the numeric HTTP status code and, when present, the HTTP reason phrase (`statusText`). Some HTTP/2 responses omit `statusText`, in which case the message contains only the status code — the status code is therefore always surfaced in the message, never empty.

Message format: `EP API request failed: <status>[ <statusText>]`

#### Example

    // HTTP/1.1 with a reason phrase
    throw new APIError('EP API request failed: 404 Not Found', 404, { endpoint: '/meps/999999' });

    // HTTP/2 where statusText is empty
    throw new APIError('EP API request failed: 404', 404, { endpoint: '/meps/999999' });

#### Hierarchy

- Error
  - APIError

- Defined in clients/ep/baseClient.ts:143

##### Index

### Constructors

constructor

### Properties

details?
statusCode?

## Constructors

### constructor

- new APIError(message: string, statusCode?: number, details?: unknown): APIError

  #### Parameters

  - message: string
  - `Optional` statusCode: number
  - `Optional` details: unknown

  #### Returns APIError

  Overrides Error.constructor

  - Defined in clients/ep/baseClient.ts:144

## Properties

### `Optional` details

details?: unknown

- Defined in clients/ep/baseClient.ts:147

### `Optional` statusCode

statusCode?: number

- Defined in clients/ep/baseClient.ts:146