aboutsummaryrefslogtreecommitdiff
path: root/error.h
blob: 780e8502cb399e0e561e98065aba5c9a84d3e7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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&aacute;ndar de C.
 */
typedef enum ErrorType {
	/** El c&oacute;digo de escaneo de tecla especificado no es
	 *  v&aacute;lido.
	 */
	ERR_INVALID_SCANCODE = 0,

	/** Se ha pasado un puntero nulo a una funci&oacute;n incorrectamente.
	 */
	ERR_NULL_PARAM = 1,

	/** Un par&aacute;metro de funci&oacute;n est&aacute; fuera de rango. */
	ERR_OUT_OF_RANGE = 2,

	/** El fichero de entrada no es v&aacute;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 &uacute;ltimo error que ha tenido lugar en la biblioteca
 * est&acute;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