Banjo API 1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
218#ifndef BJ_ERROR_H
219#define BJ_ERROR_H
220
221#include <banjo/api.h>
222
251 BJ_ERROR_NONE = 0x00000000,
252
253 // Kind 0x01: General/Unspecified errors
255 BJ_ERROR = 0x00000001,
260
261 // Kind 0x02: System/OS errors
263 BJ_ERROR_SYSTEM = 0x00000002,
271 BJ_ERROR_DISPOSE = 0x00000402,
272
273 // Kind 0x03: I/O errors
275 BJ_ERROR_IO = 0x00000003,
280
281 // Kind 0x04: Data validation errors
288
289 // Kind 0x05: Video subsystem errors
291 BJ_ERROR_VIDEO = 0x00000005,
292
293 // Kind 0x06: Audio subsystem errors
295 BJ_ERROR_AUDIO = 0x00000006,
296
297 // Kind 0x07: Network subsystem errors
299 BJ_ERROR_NETWORK = 0x00000007,
304};
305
319#define bj_error_code_kind(code) ((code) & 0x000000FFu)
320
331#define bj_error_code_is_user(code) (((code) >> 24) & 0xFFu)
332
343struct bj_error;
344
365 struct bj_error** error,
366 uint32_t code,
367 const char* message
368);
369
388 struct bj_error** error,
389 uint32_t code,
390 const char* format,
391 ...
392);
393
419 struct bj_error** dest,
420 struct bj_error* src
421);
422
440 struct bj_error** dest,
441 struct bj_error* src,
442 const char* format,
443 ...
444);
445
467 struct bj_error** error,
468 const char* prefix
469);
470
485 struct bj_error** error,
486 const char* format,
487 ...
488);
489
500 const struct bj_error* error
501);
502
516 struct bj_error** error
517);
518
538 const struct bj_error* error,
539 uint32_t code
540);
541
559 const struct bj_error* error,
560 uint32_t kind
561);
562
570 const struct bj_error* error
571);
572
583 const struct bj_error* error
584);
585
586#endif
General-purpose definitions for Banjo API.
struct bj_error bj_error
Definition api.h:333
#define BANJO_EXPORT
Definition api.h:163
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:257
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:249
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:255
@ BJ_ERROR_CANNOT_ALLOCATE
Memory allocation failed.
Definition error.h:267
@ BJ_ERROR_FILE_NOT_FOUND
Requested file was not found.
Definition error.h:265
@ BJ_ERROR_CANNOT_READ
Error while reading from a file or stream.
Definition error.h:277
@ BJ_ERROR_CANNOT_WRITE
Error while writing to a file or stream.
Definition error.h:279
@ BJ_ERROR_DISPOSE
System component cleanup failed.
Definition error.h:271
@ BJ_ERROR_SYSTEM
Generic operating system error.
Definition error.h:263
@ BJ_ERROR_NONE
No error occurred.
Definition error.h:251
@ BJ_ERROR_NETWORK
Error in network subsystem.
Definition error.h:299
@ BJ_ERROR_INCORRECT_VALUE
Value does not match expected value.
Definition error.h:287
@ BJ_ERROR_UNSUPPORTED
Operation not supported on this platform or configuration.
Definition error.h:257
@ BJ_ERROR_INVALID_DATA
Generic invalid data error.
Definition error.h:283
@ BJ_ERROR_NOT_IMPLEMENTED
Feature not yet implemented.
Definition error.h:259
@ BJ_ERROR_VIDEO
Error in video/graphics subsystem.
Definition error.h:291
@ BJ_ERROR_AUDIO
Error in audio subsystem.
Definition error.h:295
@ BJ_ERROR_NETWORK_SOCKET
Socket error.
Definition error.h:301
@ BJ_ERROR_INVALID_FORMAT
Data format does not match expected format.
Definition error.h:285
@ BJ_ERROR_NETWORK_TIMEOUT
Operation timed out.
Definition error.h:303
@ BJ_ERROR_IO
Generic I/O error.
Definition error.h:275
@ BJ_ERROR_INITIALIZE
System component initialisation failed.
Definition error.h:269