Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
58#ifndef BJ_ERROR_H
59#define BJ_ERROR_H
60
61#include <banjo/api.h>
62
91 BJ_ERROR_NONE = 0x00000000,
92
93 // Kind 0x01: General/Unspecified errors
95 BJ_ERROR = 0x00000001,
100
101 // Kind 0x02: System/OS errors
103 BJ_ERROR_SYSTEM = 0x00000002,
111 BJ_ERROR_DISPOSE = 0x00000402,
112
113 // Kind 0x03: I/O errors
115 BJ_ERROR_IO = 0x00000003,
120
121 // Kind 0x04: Data validation errors
128
129 // Kind 0x05: Video subsystem errors
131 BJ_ERROR_VIDEO = 0x00000005,
132
133 // Kind 0x06: Audio subsystem errors
135 BJ_ERROR_AUDIO = 0x00000006,
136};
137
151#define bj_error_code_kind(code) ((code) & 0x000000FFu)
152
163#define bj_error_code_is_user(code) (((code) >> 24) & 0xFFu)
164
175struct bj_error;
176
197 struct bj_error** error,
198 uint32_t code,
199 const char* message
200);
201
220 struct bj_error** error,
221 uint32_t code,
222 const char* format,
223 ...
224);
225
251 struct bj_error** dest,
252 struct bj_error* src
253);
254
272 struct bj_error** dest,
273 struct bj_error* src,
274 const char* format,
275 ...
276);
277
299 struct bj_error** error,
300 const char* prefix
301);
302
317 struct bj_error** error,
318 const char* format,
319 ...
320);
321
332 const struct bj_error* error
333);
334
348 struct bj_error** error
349);
350
370 const struct bj_error* error,
371 uint32_t code
372);
373
391 const struct bj_error* error,
392 uint32_t kind
393);
394
402 const struct bj_error* error
403);
404
415 const struct bj_error* error
416);
417
418#endif
General-purpose definitions for Banjo API.
struct bj_error bj_error
Definition api.h:275
#define BANJO_EXPORT
Definition api.h:106
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:200
void bj_propagate_prefixed_error(struct bj_error **dest, struct bj_error *src, const char *format,...)
Propagates an error with an added prefix.
void bj_prefix_error(struct bj_error **error, const char *prefix)
Adds a prefix to an existing error's message.
const char * bj_error_message(const struct bj_error *error)
Gets the error message from an error object.
bj_bool bj_error_matches_kind(const struct bj_error *error, uint32_t kind)
Checks if an error belongs to a specific error kind (category).
struct bj_error * bj_copy_error(const struct bj_error *error)
Creates a copy of an error.
void bj_clear_error(struct bj_error **error)
Frees an error and sets the pointer to NULL.
void bj_propagate_error(struct bj_error **dest, struct bj_error *src)
Propagates an error to the caller's error location.
bj_error_code
A numeric representation of an error in Banjo.
Definition error.h:89
void bj_set_error(struct bj_error **error, uint32_t code, const char *message)
Creates a new error with a literal message.
void bj_prefix_error_fmt(struct bj_error **error, const char *format,...)
Adds a formatted prefix to an existing error's message.
bj_bool bj_error_matches(const struct bj_error *error, uint32_t code)
Checks if an error matches a specific error code.
void bj_set_error_fmt(struct bj_error **error, uint32_t code, const char *format,...)
Creates a new error with a formatted message.
@ BJ_ERROR
General unspecified error.
Definition error.h:95
@ BJ_ERROR_CANNOT_ALLOCATE
Memory allocation failed.
Definition error.h:107
@ BJ_ERROR_FILE_NOT_FOUND
Requested file was not found.
Definition error.h:105
@ BJ_ERROR_CANNOT_READ
Error while reading from a file or stream.
Definition error.h:117
@ BJ_ERROR_CANNOT_WRITE
Error while writing to a file or stream.
Definition error.h:119
@ BJ_ERROR_DISPOSE
System component cleanup failed.
Definition error.h:111
@ BJ_ERROR_SYSTEM
Generic operating system error.
Definition error.h:103
@ BJ_ERROR_NONE
No error occurred.
Definition error.h:91
@ BJ_ERROR_INCORRECT_VALUE
Value does not match expected value.
Definition error.h:127
@ BJ_ERROR_UNSUPPORTED
Operation not supported on this platform or configuration.
Definition error.h:97
@ BJ_ERROR_INVALID_DATA
Generic invalid data error.
Definition error.h:123
@ BJ_ERROR_NOT_IMPLEMENTED
Feature not yet implemented.
Definition error.h:99
@ BJ_ERROR_VIDEO
Error in video/graphics subsystem.
Definition error.h:131
@ BJ_ERROR_AUDIO
Error in audio subsystem.
Definition error.h:135
@ BJ_ERROR_INVALID_FORMAT
Data format does not match expected format.
Definition error.h:125
@ BJ_ERROR_IO
Generic I/O error.
Definition error.h:115
@ BJ_ERROR_INITIALIZE
System component initialization failed.
Definition error.h:109