meta: rename to fx

This commit is contained in:
2026-03-16 10:35:43 +00:00
parent 84df46489a
commit e9d0e323f0
233 changed files with 12875 additions and 12869 deletions

View File

@@ -1,5 +1,5 @@
#include <blue/core/error.h>
#include <blue/term/print.h>
#include <fx/core/error.h>
#include <fx/term/print.h>
#include <stdio.h>
enum sample_code {
@@ -13,25 +13,25 @@ enum sample_msg {
SAMPLE_MSG_A_TEMPLATED_MSG,
};
static const b_error_definition sample_errors[] = {
B_ERROR_DEFINITION(SAMPLE_OK, "OK", "Success"),
B_ERROR_DEFINITION(SAMPLE_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
B_ERROR_DEFINITION_TEMPLATE(
static const fx_error_definition sample_errors[] = {
FX_ERROR_DEFINITION(SAMPLE_OK, "OK", "Success"),
FX_ERROR_DEFINITION(SAMPLE_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
FX_ERROR_DEFINITION_TEMPLATE(
SAMPLE_ERR_FILE_READ_FAILED, "FILE_READ_FAILED",
"Failed to read file @i[filepath]",
B_ERROR_TEMPLATE_PARAM(
"filepath", B_ERROR_TEMPLATE_PARAM_STRING, "%s")),
FX_ERROR_TEMPLATE_PARAM(
"filepath", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
};
static const b_error_msg sample_error_msg[] = {
B_ERROR_MSG_TEMPLATE(
static const fx_error_msg sample_error_msg[] = {
FX_ERROR_MSG_TEMPLATE(
SAMPLE_MSG_A_TEMPLATED_MSG, "A templated message: @e[param1]",
B_ERROR_TEMPLATE_PARAM(
"param1", B_ERROR_TEMPLATE_PARAM_STRING, "%s")),
FX_ERROR_TEMPLATE_PARAM(
"param1", FX_ERROR_TEMPLATE_PARAM_STRING, "%s")),
};
static const char *sample_code_to_string(
const struct b_error_vendor *vendor, b_error_status_code code)
const struct fx_error_vendor *vendor, fx_error_status_code code)
{
switch (code) {
case SAMPLE_OK:
@@ -45,7 +45,7 @@ static const char *sample_code_to_string(
}
}
static b_error_vendor sample_vendor = {
static fx_error_vendor sample_vendor = {
.v_name = "Sample",
.v_error_definitions = sample_errors,
.v_error_definitions_length = sizeof sample_errors,
@@ -53,31 +53,31 @@ static b_error_vendor sample_vendor = {
.v_msg_length = sizeof sample_error_msg,
};
static b_result error_return_3(void)
static fx_result error_return_3(void)
{
b_result err = b_error_with_string(
fx_result err = fx_error_with_string(
&sample_vendor, SAMPLE_ERR_IO_FAILURE,
"I/O failure while reading file");
b_error_add_submsg_string(
err, B_ERROR_SUBMSG_ERROR, "An @e{error} message");
b_error_add_submsg_string(
err, B_ERROR_SUBMSG_WARNING, "A @w{warning} message");
b_error_add_submsg_template(
err, B_ERROR_SUBMSG_WARNING, SAMPLE_MSG_A_TEMPLATED_MSG,
B_ERROR_PARAM("param1", "Hello!"));
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_ERROR, "An @e{error} message");
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_WARNING, "A @w{warning} message");
fx_error_add_submsg_template(
err, FX_ERROR_SUBMSG_WARNING, SAMPLE_MSG_A_TEMPLATED_MSG,
FX_ERROR_PARAM("param1", "Hello!"));
return err;
}
static b_result error_return_2(void)
static fx_result error_return_2(void)
{
return b_result_propagate(error_return_3());
return fx_result_propagate(error_return_3());
}
static b_result error_return_1(void)
static fx_result error_return_1(void)
{
return b_result_propagate(error_return_2());
return fx_result_propagate(error_return_2());
}
struct param {
@@ -100,39 +100,39 @@ static void __test(struct param params[])
#define test(...) __test((struct param[]) {__VA_ARGS__, {}})
static b_result some_operation(void)
static fx_result some_operation(void)
{
b_result result = error_return_2();
if (b_result_is_error(result)) {
b_result err = b_error_with_template(
fx_result result = error_return_2();
if (fx_result_is_error(result)) {
fx_result err = fx_error_with_template(
&sample_vendor, SAMPLE_ERR_FILE_READ_FAILED,
B_ERROR_PARAM("filepath", "src/Manifest.json"));
b_error_add_submsg_string(
err, B_ERROR_SUBMSG_INFO,
FX_ERROR_PARAM("filepath", "src/Manifest.json"));
fx_error_add_submsg_string(
err, FX_ERROR_SUBMSG_INFO,
"An @i{informational} message");
b_error_caused_by_b_status(result, B_ERR_IO_FAILURE);
b_result err2 = b_error_caused_by(err, result);
fx_error_caused_by_fx_status(result, FX_ERR_IO_FAILURE);
fx_result err2 = fx_error_caused_by(err, result);
return err2;
}
return B_RESULT_SUCCESS;
return FX_RESULT_SUCCESS;
}
int main(void)
{
b_set_error_report_function(b_enhanced_error_reporter, B_ERROR_REPORT_ALL);
fx_set_error_report_function(fx_enhanced_error_reporter, FX_ERROR_REPORT_ALL);
test(PARAM("Hello", 1), PARAM("Goodbye", 2));
b_result err;
if (B_CATCH(err, some_operation())) {
b_throw(err);
fx_result err;
if (FX_CATCH(err, some_operation())) {
fx_throw(err);
}
b_throw_status(B_ERR_INVALID_ARGUMENT);
b_throw_status_string(B_ERR_INVALID_ARGUMENT, "Hello!");
fx_throw_status(FX_ERR_INVALID_ARGUMENT);
fx_throw_status_string(FX_ERR_INVALID_ARGUMENT, "Hello!");
return 0;
}