> 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

## Details

It is emitted for errors or unexpected situations during capture.

**Event:** `exceptionCaptured`

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

### Syntax

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

### Received object

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

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

**Values `exceptionType` — terminals**:

| Value                        | Description                               |
| ---------------------------- | ----------------------------------------- |
| `AndroidWebViewBehaviour`    | The widget cannot run in 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`              | Misformatted configuration property.      |
| `UnknownInternalError`       | Unknown internal error.                   |
| `SpoofingDetected`           | Spoofing attempt detected (antispoof).    |
| `ActiveLivenessError`        | The active liveness check has failed.     |

**Values `exceptionType` — extraction**:

| Value                         | Description                               |
| ----------------------------- | ----------------------------------------- |
| `ErrorTimeout`                | The extraction timeout has been exceeded. |
| `FaceNotFound`                | No face found.                            |
| `EyesNotFound`                | No eyes found.                            |
| `AngleExceeded`               | The face is not straight.                 |
| `DarkLightError`              | Insufficient light.                       |
| `TooManyFaces`                | More than one face detected.              |
| `OccludedEyes`                | Occluded eyes.                            |
| `OccludedMouth`               | Occluded mouth.                           |
| `ExternalCameraChangeTimeout` | Timeout when switching 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 filtering and reacting to the different types of error during capture.

### Considerations

The payload is in `event.detail.detail` (see [event format](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos.md#formato-de-los-eventos)). Terminal exceptions show an error view and close the widget after [errorTimer](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/propiedades/errortimer.md).

The SPI codes are aligned with the table of [results](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/resultados.md#codigos-de-error). For `ExternalCameraChangeTimeout`, see the value emitted in `code`.

***

## 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;
});
```
