Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
25#ifndef BJ_ERROR_H
26#define BJ_ERROR_H
27
28#include <banjo/api.h>
29#include <banjo/memory.h>
30
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,
92};
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
131struct bj_error {
132 uint32_t code;
134};
135
153 struct bj_error** error,
154 uint32_t code,
155 const char* message
156);
157
170 const struct bj_error* error,
171 uint32_t code
172);
173
192 struct bj_error* source,
193 struct bj_error** destination
194);
195
201 struct bj_error** error
202);
203
204#endif
General-purpose definitions for Banjo API.
#define BANJO_EXPORT
Definition api.h:155
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:249
uint32_t code
Error code.
Definition error.h:132
char message[127+1]
Optional error description.
Definition error.h:133
bj_bool bj_check_error(const struct bj_error *error, uint32_t code)
Checks if the given error matches the error code.
#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_forward_error(struct bj_error *source, struct bj_error **destination)
Forward an error into another error location.
void bj_clear_error(struct bj_error **error)
Clears the given error location.
bj_error_code
A numeric representation of an error in Banjo.
Definition error.h:70
void bj_set_error(struct bj_error **error, uint32_t code, const char *message)
Fills in a bj_error object with given code and message.
@ 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.