# PdfViewerErrorCode reference

Machine-readable category of a `PdfViewerError`, for handling failures such as a missing password or an HTTP error in code.

## Used by

- [Error states](https://react-pdf-viewer-chi.vercel.app/react-pdf-viewer/error-states.md)

## Import

```ts
import type { PdfViewerErrorCode } from '@kingtech/react-pdf-viewer';
```

Signature: `type PdfViewerErrorCode = 'PDFJS_LOAD_FAILED' | 'NETWORK_ERROR' | 'HTTP_ERROR' | 'INVALID_PDF' | 'PASSWORD_REQUIRED' | 'INCORRECT_PASSWORD' | 'RENDER_FAILED' | 'DOWNLOAD_FAILED' | 'PRINT_FAILED' | 'UNKNOWN'`

## Properties

| Name | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `PDFJS_LOAD_FAILED` | `'PDFJS_LOAD_FAILED'` | — | No | The `pdfjs-dist` module or its worker failed to load. |
| `NETWORK_ERROR` | `'NETWORK_ERROR'` | — | No | `fetch` rejected: offline, CORS, DNS, … |
| `HTTP_ERROR` | `'HTTP_ERROR'` | — | No | The server answered with a non-2xx status (`status` is set). |
| `INVALID_PDF` | `'INVALID_PDF'` | — | No | The bytes are not a valid PDF. |
| `PASSWORD_REQUIRED` | `'PASSWORD_REQUIRED'` | — | No | The document is encrypted and no password was supplied. |
| `INCORRECT_PASSWORD` | `'INCORRECT_PASSWORD'` | — | No | The supplied password is wrong. |
| `RENDER_FAILED` | `'RENDER_FAILED'` | — | No | A page failed to render. |
| `DOWNLOAD_FAILED` | `'DOWNLOAD_FAILED'` | — | No | Saving the document failed. |
| `PRINT_FAILED` | `'PRINT_FAILED'` | — | No | Printing failed. |
| `UNKNOWN` | `'UNKNOWN'` | — | No | Anything else. |

## Source

[packages/react-pdf-viewer/src/types.ts](https://github.com/kiralygyula92/react-pdf-viewer/blob/main/packages/react-pdf-viewer/src/types.ts#L68)

