> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/eventos/exceptioncaptured.md).

# exceptionCaptured

An exception occurred during execution.

## Details

Emitted when errors or unexpected situations occur during capture.

**Event:** `exceptionCaptured`

**Type:** `FacephiSelphidWidgetCustomEvent<ExceptionCapturedEvent>` | `CustomEvent<ExceptionCapturedEvent>`

### Syntax

```typescript
selphid.addEventListener('exceptionCaptured', onExceptionCaptured);
```

### Received object

The useful payload is of type `SelphidExceptionCapturedDetail` and is available at `event.detail.detail`:

* `eventType` (`string`): Type of event emitted.
* `exceptionType` (`string`): Exception type (`ExceptionType`).
* `message` (`string`): Brief error description.
* `code` (`string`): Error code associated with `exceptionType`.

**Values `exceptionType` — terminal**:

| Value                         | Description                                    |
| ----------------------------- | ---------------------------------------------- |
| `AndroidWebViewBehaviour`     | The widget cannot run in the Android WebView.  |
| `BrowserApiNotCompatible`     | The browser is not compatible.                 |
| `CameraHardwareError`         | Error accessing the camera.                    |
| `PermissionsDenied`           | Required permissions not granted.              |
| `CameraPermissionDenied`      | Camera permission denied.                      |
| `MicrophonePermissionDenied`  | Microphone permission denied.                  |
| `SettingsError`               | Malformed configuration property.              |
| `UnknownInternalError`        | Unknown internal error.                        |
| `ExternalCameraChangeTimeout` | Timeout while switching to an external camera. |

**Values `exceptionType` — extraction**:

| Value          | Description                             |
| -------------- | --------------------------------------- |
| `ErrorTimeout` | The extraction time limit was exceeded. |

**Values `code`**:

| `exceptionType`              | Code      |
| ---------------------------- | --------- |
| `AndroidWebViewBehaviour`    | `SPD_318` |
| `UnknownInternalError`       | `SPD_329` |
| `CameraHardwareError`        | `SPD_305` |
| `PermissionsDenied`          | `SPD_332` |
| `CameraPermissionDenied`     | `SPD_301` |
| `MicrophonePermissionDenied` | `SPD_319` |
| `SettingsError`              | `SPD_320` |
| `BrowserApiNotCompatible`    | `SPD_321` |
| `ErrorTimeout`               | `SPD_001` |

## Description

This lets you filter and respond to the different error types that occur during document capture.

### Considerations

The useful payload is in `event.detail.detail` (see [event format](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/eventos.md#formato-de-los-eventos)). Terminal exceptions display an error view and close the widget after [errorTimer](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/propiedades/errortimer.md).

The SPD codes are aligned with the [results](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/resultados.md#codigos-de-error). For `ExternalCameraChangeTimeout`, see the value emitted in `code`.

In IDV flows, recoverable extraction exceptions are reported as a retry of the step and do not write a verdict for it; the verdict is determined by how the capture ends: [maxAttemptsExceeded](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphid-documentos/eventos/maxattemptsexceeded.md) or a terminal exception.

***

## Example

```jsx
<facephi-selphid-widget
    onExceptionCaptured={(event) => {
      const { exceptionType, message, code } = event.detail.detail;
      console.error(code, exceptionType, message);
    }}
/>
```

```typescript
import { type SelphidExceptionCapturedDetail } from '@facephi/sdk-web-wc';

selphid.addEventListener('exceptionCaptured', (event) => {
  const detail: SelphidExceptionCapturedDetail = event.detail.detail;
});
```
