libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
exception.c File Reference
#include "exception.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Data Structures

struct  C8_Exception
 Represents an exception. More...
 

Macros

#define C8_SYNTAX_ERROR_EXCEPTION_MESSAGE   "A syntax error was encountered in the input file."
 
#define C8_STACK_OVERFLOW_EXCEPTION_MESSAGE   "A stack overflow occurred during execution."
 
#define C8_STACK_UNDERFLOW_EXCEPTION_MESSAGE   "A stack underflow occurred during execution."
 
#define C8_IO_EXCEPTION_MESSAGE   "A file I/O error occurred during execution."
 
#define C8_INVALID_STATE_EXCEPTION_MESSAGE   "The c8 instance is in an invalid state."
 
#define C8_INVALID_PARAMETER_EXCEPTION_MESSAGE   "An invalid parameter was passed to a function."
 
#define C8_GRAPHICS_EXCEPTION_MESSAGE   "An error occurred while rendering graphics."
 
#define C8_AUDIO_EXCEPTION_MESSAGE   "An error occurred while playing audio."
 

Functions

void c8_handle_exception (C8_ExceptionCode code)
 Handles an exception by printing the corresponding error message to stderr.
 

Variables

const C8_Exception c8_exceptions []
 
char c8_exception [BUFSIZ]
 Message to print when calling c8_handle_exception with a non-zero code.
 

Detailed Description

Note
NOT EXPORTED

Stuff for handling exceptions.

Macro Definition Documentation

◆ C8_AUDIO_EXCEPTION_MESSAGE

#define C8_AUDIO_EXCEPTION_MESSAGE   "An error occurred while playing audio."

◆ C8_GRAPHICS_EXCEPTION_MESSAGE

#define C8_GRAPHICS_EXCEPTION_MESSAGE   "An error occurred while rendering graphics."

◆ C8_INVALID_PARAMETER_EXCEPTION_MESSAGE

#define C8_INVALID_PARAMETER_EXCEPTION_MESSAGE   "An invalid parameter was passed to a function."

◆ C8_INVALID_STATE_EXCEPTION_MESSAGE

#define C8_INVALID_STATE_EXCEPTION_MESSAGE   "The c8 instance is in an invalid state."

◆ C8_IO_EXCEPTION_MESSAGE

#define C8_IO_EXCEPTION_MESSAGE   "A file I/O error occurred during execution."

◆ C8_STACK_OVERFLOW_EXCEPTION_MESSAGE

#define C8_STACK_OVERFLOW_EXCEPTION_MESSAGE   "A stack overflow occurred during execution."

◆ C8_STACK_UNDERFLOW_EXCEPTION_MESSAGE

#define C8_STACK_UNDERFLOW_EXCEPTION_MESSAGE   "A stack underflow occurred during execution."

◆ C8_SYNTAX_ERROR_EXCEPTION_MESSAGE

#define C8_SYNTAX_ERROR_EXCEPTION_MESSAGE   "A syntax error was encountered in the input file."

Function Documentation

◆ c8_handle_exception()

void c8_handle_exception ( C8_ExceptionCode  code)

Handles an exception by printing the corresponding error message to stderr.

Parameters
codeThe exception code.

Variable Documentation

◆ c8_exception

char c8_exception[BUFSIZ]

Message to print when calling c8_handle_exception with a non-zero code.

◆ c8_exceptions

const C8_Exception c8_exceptions[]
Initial value:
= {
{ C8_SYNTAX_ERROR_EXCEPTION, "A syntax error was encountered in the input file." },
{ C8_STACK_OVERFLOW_EXCEPTION, "A stack overflow occurred during execution." },
{ C8_STACK_UNDERFLOW_EXCEPTION, "A stack underflow occurred during execution." },
{ C8_IO_EXCEPTION, "A file I/O error occurred during execution." },
{ C8_INVALID_STATE_EXCEPTION, "The c8 instance is in an invalid state." },
{ C8_INVALID_PARAMETER_EXCEPTION, "An invalid parameter was passed to a function." },
{ C8_GRAPHICS_EXCEPTION, "An error occurred while rendering graphics." },
{ C8_AUDIO_EXCEPTION, "An error occurred while playing audio." },
}
@ C8_IO_EXCEPTION
Definition: exception.h:34
@ C8_GRAPHICS_EXCEPTION
Definition: exception.h:37
@ C8_AUDIO_EXCEPTION
Definition: exception.h:38
@ C8_STACK_OVERFLOW_EXCEPTION
Definition: exception.h:32
@ C8_INVALID_STATE_EXCEPTION
Definition: exception.h:35
@ C8_STACK_UNDERFLOW_EXCEPTION
Definition: exception.h:33
@ C8_SYNTAX_ERROR_EXCEPTION
Definition: exception.h:31
@ C8_INVALID_PARAMETER_EXCEPTION
Definition: exception.h:36