Cub3D/sources/error.c
B.Goulard 8ee1c5f85a First shot on structures, First shot on option
option:
    Added options for help, debug, save, file using bgoulard lib
structures:
    Moved cub3d.h structures to cub3d_struct.h
    Added color, dpoint, ipoint, tile, cli, error
    Modified t_map, t_player to use previously mentioned struct :
	ipoint, dpoint, tyle
2024-11-09 01:53:22 +01:00

50 lines
1.6 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/31 11:09:00 by rparodi #+# #+# */
/* Updated: 2024/11/09 01:43:06 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
#include "cub3d.h"
#include "message_error.h"
#include <unistd.h>
const char *g_error_message[] = {
"no error",
"unknown error",
"could not open file",
"could not read file",
"bad file extension",
"invalid file name",
"missing file",
"malloc error",
"parse error",
"cli error",
"mlx error",
};
void c3_perror(t_info *info)
{
if (info->last_error == NO_ERROR)
return ;
print_error(g_error_message[info->last_error]);
}
void print_error(const char *msg)
{
ft_putstr_fd(BOLD_RED, STDERR_FILENO);
ft_putstr_fd("Error:\n", STDERR_FILENO);
ft_putstr_fd(RESET, STDERR_FILENO);
ft_putstr_fd(RED, STDERR_FILENO);
ft_putstr_fd(msg, STDERR_FILENO);
ft_putstr_fd(RESET, STDERR_FILENO);
}