-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.c
35 lines (35 loc) · 797 Bytes
/
errors.c
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
#include "monty.h"
/**
* file_error - if file does not exist
* @file_name: the name of the file
*/
void file_error(char *file_name)
{
fprintf(stderr, "Error: Can't open file %s\n", file_name);
exit(EXIT_FAILURE);
}
/**
* generic_error - generic error
* @message: the error message
* @monty_stack: the stack
*/
void generic_error(char *message, stack_t *monty_stack)
{
free_stack(monty_stack);
fprintf(stderr, "%s", message);
if (globals.file)
fclose(globals.file);
exit(EXIT_FAILURE);
}
/**
* push_error - prints push error
* @line_no: the line number
* @monty_stack: the monty stack
*/
void push_error(unsigned int line_no, stack_t *monty_stack)
{
free_stack(monty_stack);
fprintf(stderr, "L%u: usage: push integer\n", line_no);
fclose(globals.file);
exit(EXIT_FAILURE);
}