> 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/resultados.md).

# Results

On this page we will explain the different possibilities for finishing the widget capture process.

Every detail of each event (attributes, data...) has been specified on the page ([Events](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos.md)).

## Success stories

### Successful capture and extraction

When the capture of the Biometric Template is completed, the extracted results will be provided in the event `extractionFinish` ([link](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos/extractionfinish.md)).

{% hint style="info" %}
Once this event is emitted, the logic for loading the next view or Widget must be implemented adapting to the application context.
{% endhint %}

Here is an example:

```typescript
import { type ExtractionFinishEvent } from "@facephi/selphi-web-component";

const selphiWidget = document.querySelector('facephi-selphi-widget');
selphiWidget.addEventListener('extractionFinish', onExtractionFinish);

function onExtractionFinish(event: CustomEvent<ExtractionFinishEvent>) {
  const result = event.detail.detail;
  console.log('extractionFinish:', result);

  // Procesar los resultados en el backend
  saveResults(result.extractionData.bestImage, result.extractionData.templateRaw);

  // Cargar el siguiente widget o vista
  loadNextView();
}
```

***

## Error cases

It is recommended to handle the possible errors that may occur when processing the obtained data to avoid internal malfunction, incorrect use of the Widget, or brute-force attacks.

### Error codes

The widget will throw an exception if any usage or internal error occurs.

Exceptions can be of two types:

* Terminal exception: Error that will be thrown when the widget cannot continue executing. These errors can occur in incorrect environments or configurations.
* Extraction exception: Error that will be thrown during the capture or extraction flow. These errors allow the widget flow to be retried, since they are due to incorrect use of the widget by the user.

<table><thead><tr><th width="266.15625">Error</th><th width="87.30078125">Code</th><th>Description</th></tr></thead><tbody><tr><td><strong>Terminal exceptions</strong></td><td></td><td></td></tr><tr><td>AndroidWebViewBehaviour</td><td>SPI_227</td><td>Error produced after running the component in a WebView in an Android environment.</td></tr><tr><td>UnknownInternalError</td><td>SPI_235</td><td>Internal error in the widget. If the error persists, it will be necessary to contact the Facephi support team</td></tr><tr><td>CameraHardwareError</td><td>SPI_204</td><td>Error produced while accessing the device's cameras.</td></tr><tr><td>PermissionsDenied</td><td>SPI_242</td><td>Error generated by not allowing the necessary permissions for widget execution.</td></tr><tr><td>CameraPermissionDenied</td><td>SPI_201</td><td>Error because permission was not granted to use the device's camera(s).</td></tr><tr><td>MicrophonePermissionDenied</td><td>SPI_218</td><td>Error when permissions are not granted to use the device's microphone(s).</td></tr><tr><td>SettingsError</td><td>SPI_219</td><td>Error produced by an incorrect configuration.</td></tr><tr><td>BrowserApiNotCompatible</td><td>SPI_220</td><td>Error produced by an unsupported browser.</td></tr><tr><td>SpoofingDetected</td><td>SPI_221</td><td>Error generated when an injection attack is detected in the Widget.</td></tr><tr><td>ActiveLivenessError</td><td>SPI_205</td><td>Error generated when the active liveness check fails during the Widget's execution.</td></tr><tr><td><strong>Extraction exceptions</strong></td><td></td><td></td></tr><tr><td>ErrorTimeout</td><td>SPI_001</td><td>Error generated after exceeding the time limit set for extraction.</td></tr><tr><td>FaceNotFound</td><td>SPI_222</td><td>Error generated when no face is found during the capture process.</td></tr><tr><td>EyesNotFound</td><td>SPI_223</td><td>Error generated when the eyes are not detected during the capture process.</td></tr><tr><td>OccludedEyes</td><td>SPI_237</td><td>Error generated when occluded eyes are recognized during the capture process.</td></tr><tr><td>OccludedMouth</td><td>SPI_238</td><td>Error generated when an occluded mouth is recognized during the capture process.</td></tr><tr><td>DarkLightError</td><td>SPI_224</td><td>Error generated when low lighting is detected during the capture process.</td></tr><tr><td>AngleExceeded</td><td>SPI_225</td><td>Error generated when an excessive angle of the user's face is detected during the capture process.</td></tr><tr><td>TooManyFaces</td><td>SPI_226</td><td>Error generated when multiple faces are detected during the capture process.</td></tr><tr><td>NotStabilizedSunGlasses</td><td>SPI_223</td><td>Error generated when sunglasses are detected on the user during the capture process.</td></tr><tr><td>NotStabilizedNoColor</td><td>SPI_224</td><td>Error generated when no color is detected during the capture process.</td></tr></tbody></table>

***

### Time limit exceeded during the capture of the Biometric Template

With the events `extractionTimeout` ([link](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos/extractiontimeout.md)) and `timeoutErrorButtonClick` ([link](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos/timeouterrorbuttonclick.md)) it is possible to control when the user exceeds the allotted time or the attempts used.

Here is an example:

```typescript
import { type ExtractionTimeoutEvent, type TimeoutButtonClickEvent } from "@facephi/selphi-web-component";

const selphiWidget = document.querySelector('facephi-selphi-widget');
selphiWidget.addEventListener('extractionTimeout', onErrorTimeout);
selphiWidget.addEventListener('timeoutErrorButtonClick', onTimeoutButtonClick);
let userRetries = 0;

// El usuario no ha completado la extracción del patrón facial dentro del tiempo permitido
const onExtractionTimeout = (event: CustomEvent<ExtractionTimeoutEvent>) => {
  if (userRetries >= 3) {
    // Redirigir al usuario a una vista de error
    showRetriesExceededView();
  }
}

// El usuario ha hecho clic en el botón para reintentar la extracción en la vista de tiempo de espera del widget
const onTimeoutButtonClick = (event: CustomEvent<TimeoutButtonClickEvent>) => {
  userRetries++;
}
```

***

### Capture attempts exhausted

As an alternative to the manual count in the previous section, the property [maxAttempts](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/propiedades/maxattempts.md) delegates the attempt limit to the widget itself. When they are exhausted, the widget stops retrying and emits `maxAttemptsExceeded` ([link](/docs.facephi-en/sdks/sdk-web/componentes/selphi-biometria-facial/eventos/maxattemptsexceeded.md)).

Here is an example:

```typescript
import { type MaxAttemptsExceededEvent } from "@facephi/selphi-web-component";

const selphiWidget = document.querySelector('facephi-selphi-widget');
selphiWidget.maxAttempts = 3;
selphiWidget.addEventListener('maxAttemptsExceeded', onMaxAttemptsExceeded);

// El usuario ha consumido todos los intentos de captura permitidos
function onMaxAttemptsExceeded(event: CustomEvent<MaxAttemptsExceededEvent>) {
  const detail = event.detail.detail;
  console.log('maxAttemptsExceeded:', detail.message);

  // Redirigir al usuario a una vista de error
  showRetriesExceededView();
}
```

***

### The user closes the widget before document capture

This event is emitted when the user clicks the exit icon of the Widget to cancel the extraction process. Once the button is pressed, the Widget will close.

Code example

```typescript
import { type UserCancelEvent } from "@facephi/selphi-web-component";
  
const selphiWidget = document.querySelector('facephi-selphi-widget');
selphiWidget.addEventListener('userCancel', handleUserCancel);

// El usuario ha hecho clic en el ícono de salir del widget para cancelar el proceso de extracción
function handleUserCancel(event: CustomEvent<UserCancelEvent>) {
  // Redirigir al usuario a la página principal del sitio web
  goLandingPage();
}
```

***

### Terminal exceptions during the Widget lifecycle

This event is emitted when a system malfunction is detected. It can be used to identify and filter different types of errors found during the capture process.

Code example:

```typescript
import { type ExceptionCapturedEvent, type ErrorTimeoutEvent } from "@facephi/selphi-web-component";

const selphiWidget = document.querySelector('facephi-selphi-widget');
selphiWidget.addEventListener('exceptionCaptured', handleExceptionCaptured);
selphiWidget.addEventListener('errorTimeout', handleErrorTimeout);

// Se detecta un mal funcionamiento y el widget se ha detenido
function handleExceptionCaptured(event: CustomEvent<ExceptionCapturedEvent>) {
  const exceptionDetail = event.detail.detail;
  console.error('Widget Exception:', exceptionDetail.exceptionType);
}

// Se ha alcanzado el tiempo establecido en la propiedad `errorTimeout`
function handleErrorTimeout(event: CustomEvent<ErrorTimeoutEvent>) {
  const errorTimeoutDetail = event.detail.detail;
  // Redirigir al usuario a una vista de error
  showErrorView(errorTimeoutDetail.exceptionType);
}
```

***
