> 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/selphi-biometria-facial/eventos/exceptioncaptured.md).

# exceptionCaptured

An exception occurred during execution.

## Details

Emitted when errors or unexpected situations occur during capture.

**Event:** `exceptionCaptured`

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

### Syntax

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

### Received object

The useful payload is of type `SelphiExceptionCapturedDetail` and is in `event.detail.detail`:

* `eventType` (`string`): Type of event emitted.
* `exceptionType` (`string`): Exception type (`ExceptionType`).
* `message` (`string`): Brief error description.
* `code` (`string`): SPI 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.                       |
| `SpoofingDetected`           | Spoofing attempt detected (antispoof).        |
| `ActiveLivenessError`        | The active liveness check failed.             |

**Values `exceptionType` — extraction**:

| Value                         | Description                                    |
| ----------------------------- | ---------------------------------------------- |
| `ErrorTimeout`                | The extraction time limit was exceeded.        |
| `FaceNotFound`                | No face was found.                             |
| `EyesNotFound`                | No eyes were found.                            |
| `AngleExceeded`               | The face is not straight.                      |
| `DarkLightError`              | Insufficient light.                            |
| `TooManyFaces`                | More than one face detected.                   |
| `OccludedEyes`                | Eyes occluded.                                 |
| `OccludedMouth`               | Mouth occluded.                                |
| `ExternalCameraChangeTimeout` | Timeout while switching to an external camera. |

**Values `code`**:

| `exceptionType`              | Code      |
| ---------------------------- | --------- |
| `AndroidWebViewBehaviour`    | `SPI_227` |
| `UnknownInternalError`       | `SPI_235` |
| `CameraHardwareError`        | `SPI_204` |
| `PermissionsDenied`          | `SPI_242` |
| `CameraPermissionDenied`     | `SPI_201` |
| `MicrophonePermissionDenied` | `SPI_218` |
| `SettingsError`              | `SPI_219` |
| `BrowserApiNotCompatible`    | `SPI_220` |
| `SpoofingDetected`           | `SPI_221` |
| `ActiveLivenessError`        | `SPI_205` |
| `ErrorTimeout`               | `SPI_001` |
| `FaceNotFound`               | `SPI_222` |
| `EyesNotFound`               | `SPI_223` |
| `OccludedEyes`               | `SPI_237` |
| `OccludedMouth`              | `SPI_238` |
| `DarkLightError`             | `SPI_224` |
| `AngleExceeded`              | `SPI_225` |
| `TooManyFaces`               | `SPI_226` |

## Description

Allows you to filter and react to different types of errors during capture.

### Considerations

The useful payload is in `event.detail.detail` (see [event format](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/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/selphi-biometria-facial/propiedades/errortimer.md).

The SPI codes are aligned with the [results](https://docs.facephi.com/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/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/selphi-biometria-facial/eventos/maxattemptsexceeded.md) or a terminal exception.

***

## Example

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

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

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