-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_handling.c
More file actions
45 lines (42 loc) · 1.4 KB
/
error_handling.c
File metadata and controls
45 lines (42 loc) · 1.4 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_handling.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmitkovi <mmitkovi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/27 13:12:12 by tafanasi #+# #+# */
/* Updated: 2025/08/26 19:13:55 by mmitkovi ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void custom_error(char *msg)
{
rl_replace_line("", 0);
rl_on_new_line();
while (*msg)
{
if (*msg == '\n')
write(STDERR_FILENO, "\n", 1);
else
write(STDERR_FILENO, msg, 1);
msg++;
}
}
void report_error(char *command, char *detail, int is_sys_err)
{
ft_putstr_fd("minishell: ", 2);
if (command)
{
ft_putstr_fd(command, 2);
ft_putstr_fd(": ", 2);
}
if (detail)
ft_putstr_fd(detail, 2);
if (is_sys_err)
{
ft_putstr_fd(": ", 2);
ft_putstr_fd(strerror(errno), 2);
}
ft_putstr_fd("\n", 2);
}