43 lines
1.5 KiB
C
43 lines
1.5 KiB
C
/*
|
|
* FnixLib - manejo de errores.
|
|
*
|
|
* Convención general de la API:
|
|
* - Las funciones que crean un objeto devuelven un puntero; NULL indica fallo.
|
|
* - Las funciones de consulta no fallan: con un puntero NULL o un argumento
|
|
* fuera de rango devuelven 0 / false.
|
|
* - Cuando algo falla, FnixLib guarda un código y un mensaje legibles
|
|
* (por hilo), que se consultan con fnix_last_error_code() y
|
|
* fnix_last_error(). Un éxito NO borra el último error (como errno).
|
|
*/
|
|
#ifndef FNIX_ERRORS_H
|
|
#define FNIX_ERRORS_H
|
|
|
|
#include "fnix/types.h"
|
|
|
|
FNIX_BEGIN_DECLS
|
|
|
|
typedef enum FnixError {
|
|
FNIX_OK = 0,
|
|
FNIX_ERROR_INVALID_ARGUMENT, /* argumento nulo o fuera de rango */
|
|
FNIX_ERROR_OUT_OF_MEMORY, /* no se pudo reservar memoria */
|
|
FNIX_ERROR_PLATFORM, /* fallo del sistema (pantalla, ventana) */
|
|
FNIX_ERROR_UNSUPPORTED /* el sistema no ofrece lo que se necesita */
|
|
} FnixError;
|
|
|
|
/* Descripción corta y fija de un código. Nunca devuelve NULL. */
|
|
const char *fnix_error_string(FnixError error);
|
|
|
|
/* Código del último error ocurrido en este hilo (FNIX_OK si no hubo ninguno). */
|
|
FnixError fnix_last_error_code(void);
|
|
|
|
/* Mensaje detallado del último error. Nunca devuelve NULL; es "" si no hubo
|
|
* errores. El puntero es válido hasta el siguiente error en este hilo. */
|
|
const char *fnix_last_error(void);
|
|
|
|
/* Olvida el último error de este hilo. */
|
|
void fnix_clear_error(void);
|
|
|
|
FNIX_END_DECLS
|
|
|
|
#endif /* FNIX_ERRORS_H */
|