~nloomans/ft_select

ref: a4ef762331941c5e33670f7bf81eb964fb761edb ft_select/src/error.c -rw-r--r-- 1.3 KiB
a4ef7623Noah Loomans fix build on linux 2 years ago
                                                                                
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        ::::::::            */
/*   ft_select                                          :+:    :+:            */
/*                                                     +:+                    */
/*   Author: Noah Loomans                             +#+                     */
/*           <nloomans@student.codam.nl>             +#+                      */
/*                                                  #+#    #+#                */
/*   License: GPLv3                                ########   odam.nl         */
/*                                                                            */
/* ************************************************************************** */

#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');
}