---
title: ErrorHistory
slug: oip-next/mirchrdfvjykyq0v3w6f6
createdAt: 2024-04-17T13:52:30.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é |
| ------ | --------- |

## Liste des propriétés

| Nom         | Type              | Dernière version modifiée | Description                                                           | Getter                     | Setter                     | Deprecated |
| ----------- | ----------------- | ------------------------- | --------------------------------------------------------------------- | -------------------------- | -------------------------- | ---------- |
| code        | `String`          | 2.9.0                     | Identifie le domaine de l'erreur                                      | getErrorHistoryCode        | setErrorHistoryCode        | -          |
| createdAt   | `Date`            |                           | Date de création de l'entité `ErrorHistory`                           | getErrorHistoryCreatedAt   | Lecture seule              | -          |
| createdBy   | `String`          |                           | Utilisateur à l'origine de la création de l'entité `ErrorHistory`     | getErrorHistoryCreatedBy   | Lecture seule              | -          |
| criticality | `CriticalityEnum` | 2.9.0                     | Niveau d'impact business                                              | getErrorHistoryCriticality | setErrorHistoryCriticality | -          |
| errorTime   | `Date`            | 2.9.0                     | Date en millisecondes à laquelle l'erreur est survenue                | getErrorHistoryErrorTime   | setErrorHistoryErrorTime   | -          |
| id          | `String`          |                           | Identifiant unique de l'entité `ErrorHistory`                         | getErrorHistoryId          | Lecture seule              | -          |
| metadata    | `Json`            | 2.9.0                     | Informations additionnelles et/ou contextuelles                       | getErrorHistoryMetadata    | setErrorHistoryMetadata    | -          |
| stack       | `Json`            | 2.9.0                     | Error stack technique                                                 | getErrorHistoryStack       | setErrorHistoryStack       | -          |
| status      | `Json`            | 2.9.0                     | Status du cycle impacté par l'erreur                                  | getErrorHistoryStatus      | setErrorHistoryStatus      | -          |
| type        | `TypeEnum`        | 2.9.0                     | Indique le type de l'erreur                                           | getErrorHistoryType        | setErrorHistoryType        | -          |
| updatedAt   | `Date`            |                           | Date de modification de l'entité `ErrorHistory`                       | getErrorHistoryUpdatedAt   | Lecture seule              | -          |
| updatedBy   | `String`          |                           | Utilisateur à l'origine de la modification de l'entité `ErrorHistory` | getErrorHistoryUpdatedBy   | Lecture seule              | -          |

## Enums

### CriticalityEnum

- `CriticalityEnum.CRITICAL`
- `CriticalityEnum.HIGH`
- `CriticalityEnum.LOW`
- `CriticalityEnum.MEDIUM`

### TypeEnum

- `TypeEnum.ERROR`
- `TypeEnum.INFO`
- `TypeEnum.WARNING`

## Exemple

```javascript
import { Entities } from '@fasstech/oip-core';
import { getErrorHistoryCode, getErrorHistoryCriticality, getErrorHistoryErrorTime, getErrorHistoryMetadata, getErrorHistoryStack, getErrorHistoryStatus, getErrorHistoryType, geterrorHistoryId, setErrorHistoryCode, setErrorHistoryCriticality, setErrorHistoryErrorTime, setErrorHistoryMetadata, setErrorHistoryStack, setErrorHistoryStatus, setErrorHistoryType } from '@fasstech/oip-core/entities/errorHistory';
import { CriticalityEnum, TypeEnum } from '@fasstech/oip-core/entities/errorHistory/enums';
import { getProjectId } from '@fasstech/oip-core/entities/project';

(async () => {
  let ProjectEntity = await Entities('Project').get({ id: projectId });
  const ErrorHistoryEntity = await Entities('ErrorHistory').create();
  
  setErrorHistoryCode('code', ErrorHistoryEntity);
  setErrorHistoryCriticality(CriticalityEnum.MEDIUM, ErrorHistoryEntity);
  setErrorHistoryErrorTime(new Date('2017-01-01'), ErrorHistoryEntity);
  setErrorHistoryMetadata({ metadata: 'foo' }, ErrorHistoryEntity);
  setErrorHistoryStack({ stack: 'foo' }, ErrorHistoryEntity);
  setErrorHistoryStatus({ status: 'foo' }, ErrorHistoryEntity);
  setErrorHistoryType(TypeEnum.WARNING, ErrorHistoryEntity);
  
  ProjectEntity = await Entities('ErrorHistory').save(ProjectEntity, ErrorHistoryEntity);
  await Entities('Project').save(ProjectEntity);
  
  const ProjectEntityToTest = await Entities('Project').get({ id: getProjectId(ProjectEntity) });
  const ErrorHistoryEntityToTest = await Entities('ErrorHistory').get(ProjectEntityToTest, getErrorHistoryId(ErrorHistoryEntity));
  
  getErrorHistoryCode(ErrorHistoryEntityToTest); // 'code'
  getErrorHistoryCriticality(ErrorHistoryEntityToTest); // CriticalityEnum.MEDIUM
  getErrorHistoryErrorTime(ErrorHistoryEntityToTest); // new Date('2017-01-01')
  getErrorHistoryMetadata(ErrorHistoryEntityToTest); // { metadata: 'foo' }
  getErrorHistoryStack(ErrorHistoryEntityToTest); // { stack: 'foo' }
  getErrorHistoryStatus(ErrorHistoryEntityToTest); // { status: 'foo' }
  getErrorHistoryType(ErrorHistoryEntityToTest); // TypeEnum.WARNING
})();
```
