-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.c
55 lines (50 loc) · 1.14 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "monty.h"
/**
* usage_error - Prints Usage error message.
* Return: EXIT_FAILURE.
*/
int usage_error(void)
{
fprintf(stderr, "USAGE: monty file\n");
exit(EXIT_FAILURE);
}
/**
* access_error - Prints Acces error message.
* @file: The name of the file passed to the program.
* Return: EXIT_FAILURE.
*/
int access_error(char *file)
{
fprintf(stderr, "Error: Can't open file %s\n", file);
exit(EXIT_FAILURE);
}
/**
* malloc_error - Prints error messasge for malloc failure.
* Return: EXIT_FAILURE.
*/
void malloc_error(void)
{
fprintf(stderr, "Error: malloc failed\n");
exit(EXIT_FAILURE);
}
/**
* push_error - Prints Usage error message.
* @line_number: The current line in the file.
* Return: EXIT_FAILURE.
*/
int push_error(int line_number)
{
fprintf(stderr, "L%d: usage: push integer\n", line_number);
exit(EXIT_FAILURE);
}
/**
* ins_error - Prints error message for invalid instruction.
* @line_number: The current line in the file.
* @opc: The opcode passed.
* Return: EXIT_FAILURE.
*/
int ins_error(char *opc, int line_number)
{
fprintf(stderr, "L%d: unknown instruction %s\n", line_number, opc);
exit(EXIT_FAILURE);
}