Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
227#ifndef BJ_ERROR_H
228#define BJ_ERROR_H
229
230#include <banjo/api.h>
231
260 BJ_ERROR_NONE = 0x00000000,
261
262 // Kind 0x01: General/Unspecified errors
264 BJ_ERROR = 0x00000001,
269
270 // Kind 0x02: System/OS errors
272 BJ_ERROR_SYSTEM = 0x00000002,
280 BJ_ERROR_DISPOSE = 0x00000402,
281
282 // Kind 0x03: I/O errors
284 BJ_ERROR_IO = 0x00000003,
289
290 // Kind 0x04: Data validation errors
300
301 // Kind 0x05: Video subsystem errors
303 BJ_ERROR_VIDEO = 0x00000005,
304
305 // Kind 0x06: Audio subsystem errors
307 BJ_ERROR_AUDIO = 0x00000006,
308
309 // Kind 0x07: Network subsystem errors
311 BJ_ERROR_NETWORK = 0x00000007,
316};
317
319#define BJ_ERROR_INCORRECT_VALUE BJ_ERROR_INVALID_DOMAIN
320
334#define bj_error_code_kind(code) ((code) & 0x000000FFu)
335
346#define bj_error_code_is_user(code) (((code) >> 24) & 0xFFu)
347
358struct bj_error;
359
384 struct bj_error** error,
385 uint32_t code,
386 const char* message
387);
388
414 struct bj_error** error,
415 uint32_t code,
416 const char* format,
417 ...
418);
419
446 struct bj_error** dest,
447 struct bj_error* src
448);
449
471 struct bj_error** dest,
472 struct bj_error* src,
473 const char* format,
474 ...
475);
476
502 struct bj_error** error,
503 const char* prefix
504);
505
525 struct bj_error** error,
526 const char* format,
527 ...
528);
529
540 const struct bj_error* error
541);
542
557 struct bj_error** error
558);
559
579 const struct bj_error* error,
580 uint32_t code
581);
582
600 const struct bj_error* error,
601 uint32_t kind
602);
603
611 const struct bj_error* error
612);
613
624 const struct bj_error* error
625);
626
627#endif
General-purpose definitions for Banjo API.
struct bj_error bj_error
Definition api.h:348
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
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:258
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:264
@ BJ_ERROR_CANNOT_ALLOCATE
Memory allocation failed.
Definition error.h:276
@ BJ_ERROR_FILE_NOT_FOUND
Requested file was not found.
Definition error.h:274
@ BJ_ERROR_CANNOT_READ
Error while reading from a file or stream.
Definition error.h:286
@ BJ_ERROR_CANNOT_WRITE
Error while writing to a file or stream.
Definition error.h:288
@ BJ_ERROR_DISPOSE
System component cleanup failed.
Definition error.h:280
@ BJ_ERROR_SYSTEM
Generic operating system error.
Definition error.h:272
@ BJ_ERROR_NONE
No error occurred.
Definition error.h:260
@ BJ_ERROR_INVALID_DOMAIN
A present value lies outside the domain its call accepts, such as a dimension of 0,...
Definition error.h:297
@ BJ_ERROR_NETWORK
Error in network subsystem.
Definition error.h:311
@ BJ_ERROR_UNSUPPORTED
Operation not supported on this platform or configuration.
Definition error.h:266
@ BJ_ERROR_INVALID_DATA
Generic invalid data error.
Definition error.h:292
@ BJ_ERROR_NOT_IMPLEMENTED
Feature not yet implemented.
Definition error.h:268
@ BJ_ERROR_VIDEO
Error in video/graphics subsystem.
Definition error.h:303
@ BJ_ERROR_AUDIO
Error in audio subsystem.
Definition error.h:307
@ BJ_ERROR_NETWORK_SOCKET
Socket error.
Definition error.h:313
@ BJ_ERROR_INVALID_FORMAT
Data format does not match expected format.
Definition error.h:294
@ BJ_ERROR_NETWORK_TIMEOUT
Operation timed out.
Definition error.h:315
@ BJ_ERROR_IO
Generic I/O error.
Definition error.h:284
@ BJ_ERROR_INVALID_PARAMETER
A required argument is missing, such as a NULL object or an absent callback.
Definition error.h:299
@ BJ_ERROR_INITIALIZE
System component initialisation failed.
Definition error.h:278