diff options
Diffstat (limited to 'error.h')
| -rw-r--r-- | error.h | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -0,0 +1,66 @@ +/* + * error.h -- Implementa la gestión de errores del programa. + * Copyright (C) 2018 Juan Marín Noguera + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +/** + * \file error.h Implementa la gestión de errores del programa. + */ + +#ifndef __ERROR_H +#define __ERROR_H + +/** Representa un tipo de error propio del programa (no de SDL ni de la + * biblioteca estándar de C. + */ +typedef enum ErrorType { + /** El código de escaneo de tecla especificado no es + * válido. + */ + ERR_INVALID_SCANCODE = 0, + + /** Se ha pasado un puntero nulo a una función incorrectamente. + */ + ERR_NULL_PARAM = 1, + + /** Un parámetro de función está fuera de rango. */ + ERR_OUT_OF_RANGE = 2, + + /** El fichero de entrada no es válido o se ha producido un error + * de lectura. + */ + ERR_INVALID_INPUT = 3 +} ErrorType; + +/** + * \brief Informa de un error del propio programa y lo finaliza. + * \param type El tipo de error. + */ +void error_exit(ErrorType type); + +/** + * \brief Informa del último error que ha tenido lugar en la biblioteca + * est´ndar de C y finaliza el programa. + */ +void error_libc_exit(); + +/** + * \brief Informa del &uactute;ltimo error que ha tenido lugar en la + * biblioteca SDL y finaliza el programa. + */ +void error_sdl_exit(); + +#endif // __ERROR_H |
