MLX42 1.0
MLX42
Loading...
Searching...
No Matches
mlx_error.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* :::::::: */
4/* mlx_error.c :+: :+: */
5/* +:+ */
6/* By: W2Wizard <main@w2wizard.dev> +#+ */
7/* +#+ */
8/* Created: 2021/12/28 02:51:54 by W2Wizard #+# #+# */
9/* Updated: 2022/11/22 08:50:15 by jvan-hal ######## odam.nl */
10/* */
11/* ************************************************************************** */
12
13#include "MLX42/MLX42_Int.h"
14
15//= Private =//
16
17// English description of the error codes.
18static const char* mlx_errors[MLX_ERRMAX] = {
19 "No Errors",
20 "File has invalid extension",
21 "Failed to open the file",
22 "PNG file is invalid or corrupted",
23 "XPM42 file is invalid or corrupted",
24 "The specified X or Y positions are out of bounds",
25 "The specified Width or Height dimensions are out of bounds",
26 "The provided image is invalid, might indicate mismanagement of images",
27 "Failed to compile the vertex shader.",
28 "Failed to compile the fragment shader.",
29 "Failed to compile the shaders.",
30 "Failed to allocate memory",
31 "Failed to initialize GLAD",
32 "Failed to initialize GLFW",
33 "Failed to create window",
34 "String is too big to be drawn",
35};
36
37/**
38 * Functions to set the error number, simply for convenience.
39 *
40 * @param val The error value.
41 * @return Always false
42 */
44{
45 mlx_errno = val;
46#ifndef NDEBUG
47 fprintf(stderr, "MLX42: %s", mlx_strerror(mlx_errno));
48#endif
49 return (false);
50}
51
52//= Public =//
53
55{
56 MLX_ASSERT(val >= 0, "Index must be positive");
57 MLX_ASSERT(val < MLX_ERRMAX, "Index out of bounds");
58
59 return (mlx_errors[val]);
60}
enum mlx_errno mlx_errno_t
mlx_errno
Definition MLX42.h:371
@ MLX_ERRMAX
Definition MLX42.h:388
#define MLX_ASSERT(cond, msg)
Definition MLX42_Int.h:45
GLuint GLfloat * val
Definition glad.h:3979
GLuint GLsizei GLsizei * length
Definition glad.h:3372
const char * mlx_strerror(mlx_errno_t val)
Definition mlx_error.c:54
static const char * mlx_errors[MLX_ERRMAX]
Definition mlx_error.c:18
bool mlx_error(mlx_errno_t val)
Definition mlx_error.c:43