Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
26#pragma once
27
28#include <banjo/api.h>
29#include <banjo/memory.h>
30
70typedef enum {
71 BJ_ERROR_NONE = 0x00000000,
72 BJ_ERROR = 0x00000001,
73 BJ_ERROR_UNSUPPORTED = 0x00000101,
75
76 BJ_ERROR_SYSTEM = 0x00000002,
79 BJ_ERROR_INITIALIZE = 0x00000302,
80 BJ_ERROR_DISPOSE = 0x00000302,
81
82 BJ_ERROR_IO = 0x00000003,
84
85 BJ_ERROR_INVALID_DATA = 0x00000004,
88
89 BJ_ERROR_VIDEO = 0x00000005,
90
91 BJ_ERROR_AUDIO = 0x00000006,
93
103#define bj_error_code_is_user (c) (((c >> 24) & 0xFF) > 0x00)
104
119#define bj_error_code_kind(c) (c & 0x000000FF)
120
122#define BJ_ERROR_MESSAGE_MAX_LEN 127
123
131typedef struct {
132 uint32_t code;
134} bj_error;
135
152BANJO_EXPORT void bj_set_error(
153 bj_error** p_error,
154 uint32_t code,
155 const char* message
156);
157
169BANJO_EXPORT bj_bool bj_error_check(
170 const bj_error* p_error,
171 uint32_t code
172);
173
191BANJO_EXPORT bj_bool bj_forward_error(
192 bj_error* p_source,
193 bj_error** p_destination
194);
195
200BANJO_EXPORT void bj_clear_error(
201 bj_error** p_error
202);
203
General-purpose definitions for Banjo API.
uint32_t code
Error code.
Definition error.h:132
char message[BJ_ERROR_MESSAGE_MAX_LEN+1]
Optional error description.
Definition error.h:133
void bj_set_error(bj_error **p_error, uint32_t code, const char *message)
Fills in a bj_error object with given code and message.
void bj_clear_error(bj_error **p_error)
Clears the given error location.
bj_bool bj_forward_error(bj_error *p_source, bj_error **p_destination)
Forward an error into another error location.
#define BJ_ERROR_MESSAGE_MAX_LEN
Maximum number of characters an error message in bj_error can hold.
Definition error.h:122
bj_bool bj_error_check(const bj_error *p_error, uint32_t code)
Checks if the given error matches the error code.
bj_error_code
A numeric representation of an error in Banjo.
Definition error.h:70
@ BJ_ERROR
General Error (unspecified)
Definition error.h:72
@ BJ_ERROR_CANNOT_ALLOCATE
Cannot allocate the specified memory block.
Definition error.h:78
@ BJ_ERROR_FILE_NOT_FOUND
The requested file was not found.
Definition error.h:77
@ BJ_ERROR_DISPOSE
A system component cannot be terminated properly.
Definition error.h:80
@ BJ_ERROR_SYSTEM
Generic OS error.
Definition error.h:76
@ BJ_ERROR_NONE
No Error.
Definition error.h:71
@ BJ_ERROR_INCORRECT_VALUE
Mismatched expected value.
Definition error.h:87
@ BJ_ERROR_UNSUPPORTED
Unsupported operation error.
Definition error.h:73
@ BJ_ERROR_INVALID_DATA
Incorrect data.
Definition error.h:85
@ BJ_ERROR_NOT_IMPLEMENTED
Unsupported operation error.
Definition error.h:74
@ BJ_ERROR_VIDEO
Error while running video layer.
Definition error.h:89
@ BJ_ERROR_AUDIO
Error while running audio layer.
Definition error.h:91
@ BJ_ERROR_CANNOT_READ_FILE
Error while attempting to read a file.
Definition error.h:83
@ BJ_ERROR_INVALID_FORMAT
Data format does not match expected format.
Definition error.h:86
@ BJ_ERROR_IO
IO-related errors.
Definition error.h:82
@ BJ_ERROR_INITIALIZE
A system component cannot be initalized.
Definition error.h:79
Error structure.
Definition error.h:131
All memory-related functions, including custom allocators.