You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9 KiB

/**
* @file errorHandling.c
* @brief Gestion des erreurs
*/
#include "main.h"
/**
* @brief Fonction d'affichage des erreurs
* @param error: Code d'erreur
* @return void
*/
void errorHandling(int error)
{
//? Exemple d'erreurs (à adapter)
if (error < 0)
{
printf("\a"); // Bip d'erreur
switch (error)
{
case -1:
printf("[ERREUR] - L'utilisateur a quitté.\n");
break;
case -2:
printf("[ERREUR] - La taille physique du tableau est dépassée.\n");
break;
case -3:
printf("[ERREUR] - L'espace disponible du tableau est insuffisant.\n");
break;
case -4:
printf("ERREUR] - Problème lors de la lecture d'un fichier.\n");
exit(1);
case -5:
printf("[ERREUR] - Problème lors de l'écriture d'un fichier.\n");
exit(2);
case -6:
printf("[ERREUR] - Le champ renseigné doit être positif.\n");
break;
case -7:
printf("[ERREUR] - L'identifiant n'existe pas.\n");
break;
case -8:
printf("[ERREUR] - La référence existe déjà.\n");
break;
default:
printf("[ERREUR] - Une erreur s'est produite.\n");
break;
}
}
}
void debugHandling(int code)
{
switch(code)
{
case 1:
printf("DEBUG: La fonction a été appelée.\n");
break;
case 2:
printf("DEBUG: La fonction a été appelée et s'est terminée correctement.\n");
break;
case 3:
printf("DEBUG: La fonction a été appelée et s'est terminée avec une erreur.\n");
break;
default:
printf("DEBUG: La fonction a été appelée avec un code inconnu.\n");
break;
}
}