libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
exception.h
Go to the documentation of this file.
1
8#ifndef C8_EXCEPTION_H
9#define C8_EXCEPTION_H
10
11#include <stdio.h>
12
16#define C8_EXCEPTION_MESSAGE_SIZE BUFSIZ
17
21#define C8_EXCEPTION(code, ...) \
22 { \
23 snprintf(c8_exception, C8_EXCEPTION_MESSAGE_SIZE, __VA_ARGS__); \
24 c8_handle_exception(code); \
25 }
26
30typedef enum {
49
54
56
57#endif
char c8_exception[BUFSIZ]
Message to print when calling c8_handle_exception with a non-zero code.
Definition: exception.c:65
C8_ExceptionCode
Exception code enum.
Definition: exception.h:30
@ C8_INVALID_CLOCK_SPEED_EXCEPTION
Definition: exception.h:46
@ C8_UNKNOWN_EXCEPTION
Definition: exception.h:38
@ C8_INVALID_SYMBOL_EXCEPTION
Definition: exception.h:36
@ C8_INVALID_ARGUMENT_EXCEPTION
Definition: exception.h:34
@ C8_MEMORY_ALLOCATION_EXCEPTION
Definition: exception.h:37
@ C8_LOAD_FILE_FAILURE_EXCEPTION
Definition: exception.h:40
@ C8_TOO_MANY_LABELS_EXCEPTION
Definition: exception.h:32
@ C8_INVALID_FONT_EXCEPTION
Definition: exception.h:45
@ C8_STACK_OVERFLOW_EXCEPTION
Definition: exception.h:33
@ C8_FAILED_GRAPHICS_INITIALIZATION_EXCEPTION
Definition: exception.h:44
@ C8_INVALID_COLOR_PALETTE_EXCEPTION
Definition: exception.h:42
@ C8_TOO_MANY_SYMBOLS_EXCEPTION
Definition: exception.h:39
@ C8_STACK_UNDERFLOW_EXCEPTION
Definition: exception.h:47
@ C8_DUPLICATE_LABEL_EXCEPTION
Definition: exception.h:35
@ C8_FILE_TOO_BIG_EXCEPTION
Definition: exception.h:41
@ C8_INVALID_INSTRUCTION_EXCEPTION
Definition: exception.h:31
@ C8_INVALID_QUIRK_EXCEPTION
Definition: exception.h:43
#define C8_EXCEPTION_MESSAGE_SIZE
Maximum size of exception message.
Definition: exception.h:16
void c8_handle_exception(C8_ExceptionCode)
Handles an exception by printing the corresponding error message to stderr.
Definition: exception.c:72