~nloomans/ft_select

ref: 22ba947acbea51c3feb6800e85ec927750dd2152 ft_select/src/error.c -rw-r--r-- 445 bytes
22ba947aNoah Loomans improve error messages 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <ft_printf.h>
#include "error.h"

t_error         errorf(char *fmt, ...)
{
	va_list		vlist;
	ssize_t		ret;
    t_error     dest;

	va_start(vlist, fmt);
	ret = ft_vsnprintf(dest.msg, sizeof(dest.msg), fmt, vlist);
	va_end(vlist);
    if (ret == -1)
        return ((t_error){
			.msg = "an error occurred during the generation of this error" });
    return (dest);
}

bool			is_error(t_error error)
{
		return (error.msg[0] != '\0');
}