40 int port_available = 0;
42 if (!port_available) {
44 "port %d is already in use", port);
63 "While initializing server: ");
76 bj_info(
"Server initialized successfully");
91 bj_info(
"Specific match: file not found");
96 bj_info(
"Kind match: this is a system error");
139 bj_info(
"Continued despite potential error (zero cost)");
147int main(
int argc,
char* argv[]) {
151 bj_info(
"=== Basic Error Handling ===");
166 bj_info(
"\n=== Error Matching ===");
169 bj_info(
"\n=== Error Copying ===");
172 bj_info(
"\n=== Zero-Cost Path ===");
int main(int argc, char *argv[])
Recoverable error handling.
void bj_propagate_prefixed_error(struct bj_error **dest, struct bj_error *src, const char *format,...)
Propagates an error with an added prefix.
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.
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_FILE_NOT_FOUND
Requested file was not found.
@ BJ_ERROR_SYSTEM
Generic operating system error.
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
void demonstrate_zero_cost(void)
void demonstrate_error_copy(void)
void load_config_file(const char *path, bj_error **error)
void demonstrate_error_matching(void)
void open_network_port(int port, bj_error **error)
void initialize_server(const char *config_path, int port, bj_error **error)
Logging utility functions.
Portable main() replacement with platform-aware entry shim.