---
title: ErrorHistory
slug: oip-next/nvaiwwudlvrs7z92fh7zz
icon: {"lucideIcon":"📘"}
createdAt: 2024-04-08T10:17:29.000Z
---

# ErrorHistory

## Description

L'entité ErrorHistory permet de stocker les détails d'une erreur liée à l'OAV. Elles sont à corréler directement avec l'impact métier pour le client. Elles sont la source de données du tableau de bord technique.

## Relations

### Ascendantes

| Entité  | Propriété    |
| ------- | ------------ |
| Project | errorHistory |

### Descendantes

| Entité | Propriété |
| ------ | --------- |

## Propriétés

| Nom            | Type                          | Description                                                                            | Validateur | Lecture seule ? | Dépréciée ? | Dernière version modifiée |
| -------------- | ----------------------------- | -------------------------------------------------------------------------------------- | ---------- | --------------- | ----------- | ------------------------- |
| criticality    | `ErrorHistoryCriticalityEnum` | Niveau d'impact business.                                                              |            |                 |             | 2.9.0                     |
| errorTime      | `Date`                        | Date en millisecondes à laquelle l'erreur est survenue.                                |            |                 |             | 2.9.0                     |
| metadata       | `Json`                        | Informations additionnelles et/ou contextuelles.                                       |            |                 |             | 2.9.0                     |
| stack          | `Json`                        | Erreur technique.                                                                      |            |                 |             | 2.9.0                     |
| status         | `Json`                        | Statut du cycle impacté par l'erreur.                                                  |            |                 |             | 2.9.0                     |
| type           | `ErrorHistoryTypeEnum`        | Indique le type de l'erreur.                                                           |            |                 |             | 2.9.0                     |
| id             | `String`                      | Identifiant de l'entité `ErrorHistory`                                                 |            | X               |             |                           |
| code           | `String`                      | Codification fonctionnelle de l'entité `ErrorHistory`                                  |            |                 |             |                           |
| externalId     | `String`                      | Identifiant de l'entité `ErrorHistory` dans le système client                          |            |                 |             |                           |
| externalCode   | `String`                      | Codification fonctionnelle de l'entité `ErrorHistory` dans le système client           |            |                 |             |                           |
| errorHistoryId | `String`                      | Identifiant public de l'entité `ErrorHistory` dans l'OIP                               |            |                 |             |                           |
| label          | `String`                      | Information relative au nom de l'entité `ErrorHistory` dans son contexte d'utilisation |            |                 |             |                           |
| createdAt      | `Date`                        | Date de création de l'entité `ErrorHistory`                                            |            | X               |             |                           |
| updatedAt      | `Date`                        | Date de modification de l'entité `ErrorHistory`                                        |            | X               |             |                           |

## Enumérations

### ErrorHistoryCriticalityEnum

- `CRITICAL`
- `HIGH`
- `LOW`
- `MEDIUM`

### ErrorHistoryTypeEnum

- `ERROR`
- `INFO`
- `WARNING`

## Enumérations génériques

Aucune enumération générique.

## Exemple

```javascript
import { Entities } from '@fasstech/oip-core';
import { getErrorHistoryCode, getErrorHistoryCriticality, getErrorHistoryErrorHistoryId, getErrorHistoryErrorTime, getErrorHistoryExternalCode, getErrorHistoryExternalId, getErrorHistoryId, getErrorHistoryLabel, getErrorHistoryMetadata, getErrorHistoryStack, getErrorHistoryStatus, getErrorHistoryType, setErrorHistoryCode, setErrorHistoryCriticality, setErrorHistoryErrorHistoryId, setErrorHistoryErrorTime, setErrorHistoryExternalCode, setErrorHistoryExternalId, setErrorHistoryLabel, setErrorHistoryMetadata, setErrorHistoryStack, setErrorHistoryStatus, setErrorHistoryType } from '@fasstech/oip-core/entities/ErrorHistory';
import { ErrorHistoryCriticalityEnum, ErrorHistoryTypeEnum } from '@fasstech/oip-core/entities/ErrorHistory/enums';
import { getProjectId } from '@fasstech/oip-core/entities/Project';

(async () => {
  let project = await Entities('Project').create();
  const errorHistory = await Entities('ErrorHistory').create();
  
  setErrorHistoryCriticality(ErrorHistoryCriticalityEnum.MEDIUM, errorHistory);
  setErrorHistoryErrorTime(new Date('2017-01-01'), errorHistory);
  setErrorHistoryMetadata({ metadata: 'foo' }, errorHistory);
  setErrorHistoryStack({ stack: 'foo' }, errorHistory);
  setErrorHistoryStatus({ status: 'foo' }, errorHistory);
  setErrorHistoryType(ErrorHistoryTypeEnum.WARNING, errorHistory);
  setErrorHistoryCode('code', errorHistory);
  setErrorHistoryExternalId('externalId', errorHistory);
  setErrorHistoryExternalCode('externalCode', errorHistory);
  setErrorHistoryErrorHistoryId('errorHistoryId', errorHistory);
  setErrorHistoryLabel('label', errorHistory);
  
  project = await Entities('ErrorHistory').save(project, errorHistory);
  await Entities('Project').save(project);
  
  const projectToTest = await Entities('Project').get({ id: getProjectId(project) });
  const errorHistoryToTest = await Entities('ErrorHistory').get(projectToTest, { filter: ({ id }) => id === getErrorHistoryId(errorHistory) });
  
  getErrorHistoryCriticality(errorHistoryToTest); // ErrorHistoryCriticalityEnum.MEDIUM
  getErrorHistoryErrorTime(errorHistoryToTest); // new Date('2017-01-01')
  getErrorHistoryMetadata(errorHistoryToTest); // { metadata: 'foo' }
  getErrorHistoryStack(errorHistoryToTest); // { stack: 'foo' }
  getErrorHistoryStatus(errorHistoryToTest); // { status: 'foo' }
  getErrorHistoryType(errorHistoryToTest); // ErrorHistoryTypeEnum.WARNING
  getErrorHistoryCode(errorHistoryToTest); // 'code'
  getErrorHistoryExternalId(errorHistoryToTest); // 'externalId'
  getErrorHistoryExternalCode(errorHistoryToTest); // 'externalCode'
  getErrorHistoryErrorHistoryId(errorHistoryToTest); // 'errorHistoryId'
  getErrorHistoryLabel(errorHistoryToTest); // 'label'
})();
```
