LOG_ERROR

Table of Contents

LOG_ERROR

Description

Writes an error-level log message. …[in] : Format string and arguments following printf-style syntax.

Success

Error message written to log output

Failure

Logging fails silently (output not guaranteed)

Usage example (Cross-references)

    
    default :
    LOG_ERROR("Invalid format specifier");
    return false;
    }
    
    if (pos < len) {
    LOG_ERROR(
    "Parsing format specifier ended, but more characters are left for parsing. Indicates invalid format "
    "specifier."
    // Error if no closing brace found
    if (brace_end >= fmt_len) {
    LOG_ERROR("Unclosed format specifier");
    return false;
    }
    // Check if we have enough arguments
    if (arg_idx >= argc) {
    LOG_ERROR("Not enough arguments for format string");
    return false;
    }
    var_width = 8;
    } else {
    LOG_ERROR(
    "Raw data writing can only be used for u8-64, i8-64, f32, f64. Either unsupported format or "
    "attempt to write a complex type."
    
    if (fmt_info.width > var_width) {
    LOG_ERROR(
    "Number of raw bytes to be written exceeds variable width. Excess data filled with zeroes."
    );
    }
    default : {
    LOG_ERROR("Unreachable code reached");
    return false;
    }
    }
    default : {
    LOG_ERROR("Unreachable code reached");
    return false;
    }
    continue;
    }
    LOG_ERROR("Unmatched closing brace");
    return false;
    } else {
    // Check if we used all arguments
    if (arg_idx < argc) {
    LOG_ERROR("Too many arguments for format string");
    return false;
    }
    if (rem_p >= 2 && p[0] == '{' && p[1] == '{') {
    if (!in || *in != '{') {
    LOG_ERROR("Expected '{' in input");
    return NULL;
    }
    } else if (rem_p >= 2 && p[0] == '}' && p[1] == '}') {
    if (!in || *in != '}') {
    LOG_ERROR("Expected '}' in input");
    return NULL;
    }
    
    if (rem_p == 0 || *p != '}') {
    LOG_ERROR("Unmatched '{' in format string");
    return NULL;
    }
    char spec_buf[32] = {0};
    if (spec_len >= sizeof(spec_buf)) {
    LOG_ERROR("Format specifier too long");
    return NULL;
    }
    
    if (arg_index >= argc) {
    LOG_ERROR("More placeholders than arguments");
    return NULL;
    }
    FmtInfo fmt_info = {0};
    if (!ParseFormatSpec(spec_buf, spec_len, &fmt_info)) {
    LOG_ERROR("Failed to parse format specifier");
    return NULL; // Error already logged by ParseFormatSpec
    }
    TypeSpecificIO *io = &argv[arg_index++];
    if (!io->reader) {
    LOG_ERROR("Missing reader function");
    return NULL;
    }
    }
    default : {
    LOG_ERROR("Invalid raw data read width specified. Must be one of 1, 2, 4 or 8.");
    return NULL;
    }
    var_width = 8;
    } else {
    LOG_ERROR(
    "Raw data reading can only be used for u8-64, i8-64, f32, f64. Either unsupported format or "
    "attempt to read a complex type."
    }
    default : {
    LOG_ERROR("Invalid raw data read width specified. Must be one of 1, 2, 4 or 8.");
    return NULL;
    }
    // Check if reading failed
    if (!next || next == in) {
    LOG_ERROR("Failed to read value for placeholder {}", LVAL(arg_index - 1));
    return NULL;
    }
    // Match exact character from format string
    if (!in || *in != *p) {
    LOG_ERROR(
    "Input '{.8}' does not match format string '{.8}'",
    LVAL(in ? in : "(null)"),
    if (!(new_pos = StrReadFmtInternal(buffer.data, fmtstr, argv, argc))) {
    if (can_rollback) {
    LOG_ERROR("Parse failed, rolling back...");
    fsetpos(file, &start_pos);
    } else {
    fsetpos(file, &start_pos);
    } else {
    LOG_ERROR("Parse failed, and rollback not possible on non-seekable input");
    }
    }
    const char *s = *str;
    if (*s != '\\') {
    LOG_ERROR("ProcessEscape called on non-escape sequence");
    return 0;
    }
    s++;
    if (!isxdigit(s[0]) || !isxdigit(s[1])) {
    LOG_ERROR("Invalid hex escape sequence");
    return 0;
    }
    }
    default :
    LOG_ERROR("Invalid escape sequence '\\{c}'", s[0]);
    return 0;
    }
    // Check for empty input
    if (!*i || !r) {
    LOG_ERROR("Empty input string");
    return i;
    }
    // If we get here with a quote, the string was unterminated
    if (quote) {
    LOG_ERROR("Unterminated quoted string");
    StrDeinit(s);
    return NULL;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse f64: empty input");
    return i;
    }
    // Validate the string is a proper floating point number
    if (!IsValidNumericString(&temp, true)) {
    LOG_ERROR("Invalid floating point format");
    StrDeinit(&temp);
    return start;
    // Use StrToF64 directly
    if (!StrToF64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse f64");
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse u8: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    u64 val;
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u8");
    StrDeinit(&temp);
    return start;
    // Check for overflow
    if (val > UINT8_MAX) {
    LOG_ERROR("Value {} exceeds u8 maximum ({})", val, UINT8_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse u16: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    u64 val;
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u16");
    StrDeinit(&temp);
    return start;
    // Check for overflow
    if (val > UINT16_MAX) {
    LOG_ERROR("Value {} exceeds u16 maximum ({})", val, UINT16_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse u32: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    u64 val;
    if (!StrToU64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse u32");
    StrDeinit(&temp);
    return start;
    // Check for overflow
    if (val > UINT32_MAX) {
    LOG_ERROR("Value {} exceeds u32 maximum ({})", val, UINT32_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse u64: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    // Use base 0 to let strtoul detect the base from prefix
    if (!StrToU64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse u64");
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse i8: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    i64 val;
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i8");
    StrDeinit(&temp);
    return start;
    // Check for overflow/underflow
    if (val > INT8_MAX || val < INT8_MIN) {
    LOG_ERROR("Value {} outside i8 range ({} to {})", val, INT8_MIN, INT8_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse i16: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    i64 val;
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i16");
    StrDeinit(&temp);
    return start;
    // Check for overflow/underflow
    if (val > INT16_MAX || val < INT16_MIN) {
    LOG_ERROR("Value {} outside i16 range ({} to {})", val, INT16_MIN, INT16_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse i32: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    i64 val;
    if (!StrToI64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse i32");
    StrDeinit(&temp);
    return start;
    // Check for overflow/underflow
    if (val > INT32_MAX || val < INT32_MIN) {
    LOG_ERROR("Value {} outside i32 range ({} to {})", val, INT32_MIN, INT32_MAX);
    StrDeinit(&temp);
    return start;
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse i64: empty input");
    return i;
    }
    (temp.data[1] == 'x' || temp.data[1] == 'X' || temp.data[1] == 'b' || temp.data[1] == 'B' ||
    temp.data[1] == 'o' || temp.data[1] == 'O')) {
    LOG_ERROR("Incomplete number format");
    StrDeinit(&temp);
    return start;
    // Validate the string is a proper number
    if (!IsValidNumericString(&temp, false)) {
    LOG_ERROR("Invalid numeric format");
    StrDeinit(&temp);
    return start;
    // Use base 0 to let strtoul detect the base from prefix
    if (!StrToI64(&temp, v, NULL)) {
    LOG_ERROR("Failed to parse i64");
    StrDeinit(&temp);
    return start;
    char *result = malloc(temp.length + 1);
    if (!result) {
    LOG_ERROR("Failed to allocate memory for string");
    StrDeinit(&temp);
    return i;
    // Check for empty input
    if (!*i) {
    LOG_ERROR("Empty input string");
    return i;
    }
    
    if (i == hex_start) {
    LOG_ERROR("Invalid hex format - no digits after 0x");
    return start;
    }
    StrParseConfig config = {.base = 16};
    if (!StrToU64(&hex_str, &value, &config)) {
    LOG_ERROR("Failed to parse hex value");
    StrDeinit(&hex_str);
    return start;
    
    if (i == oct_start) {
    LOG_ERROR("Invalid octal format - no digits after 0o");
    return start;
    }
    StrParseConfig config = {.base = 8};
    if (!StrToU64(&oct_str, &value, &config)) {
    LOG_ERROR("Failed to parse octal value");
    StrDeinit(&oct_str);
    return start;
    
    if (i == bin_start) {
    LOG_ERROR("Invalid binary format - expected 0s and 1s");
    return start;
    }
    
    if (fmt_info && (fmt_info->flags & FMT_FLAG_CHAR)) {
    LOG_ERROR("Character-format reads are not supported for Int");
    return i;
    }
    
    if (!*i) {
    LOG_ERROR("Failed to parse Int: empty input");
    return i;
    }
    
    if (radix == 16 && digits_start[0] == '0' && (digits_start[1] == 'x' || digits_start[1] == 'X')) {
    LOG_ERROR("Int hex reads expect plain hex digits without a 0x prefix");
    return start;
    }
    }
    if (radix == 2 && digits_start[0] == '0' && (digits_start[1] == 'b' || digits_start[1] == 'B')) {
    LOG_ERROR("Int binary reads expect plain binary digits without a 0b prefix");
    return start;
    }
    }
    if (radix == 8 && digits_start[0] == '0' && (digits_start[1] == 'o' || digits_start[1] == 'O')) {
    LOG_ERROR("Int octal reads expect plain octal digits without a 0o prefix");
    return start;
    }
    
    if (i == digits_start) {
    LOG_ERROR("Failed to parse Int");
    return start;
    }
    
    if (*i == '_') {
    LOG_ERROR("Int reads do not accept digit separators");
    return start;
    }
    
    if (FloatFmtUsesUnsupportedFlags(fmt_info)) {
    LOG_ERROR("Float only supports decimal and scientific reading");
    return i;
    }
    
    if (!*i) {
    LOG_ERROR("Failed to parse Float: empty input");
    return i;
    }
    
    if (token_len == 0) {
    LOG_ERROR("Failed to parse Float");
    return start;
    }
    // Check for empty string
    if (!*i) {
    LOG_ERROR("Failed to parse f32: empty input");
    return i;
    }
    // Validate the string is a proper floating point number
    if (!IsValidNumericString(&temp, true)) {
    LOG_ERROR("Invalid floating point format");
    StrDeinit(&temp);
    return start;
    f64 val;
    if (!StrToF64(&temp, &val, NULL)) {
    LOG_ERROR("Failed to parse f32");
    StrDeinit(&temp);
    return start;
    bool ReadCompleteFile(const char *filename, char **data, u64 *file_size, u64 *capacity) {
    if (!filename || !data || !file_size || !capacity) {
    LOG_ERROR("invalid arguments.");
    return false;
    }
    i64 fsize = SysGetFileSize(filename);
    if (-1 == fsize) {
    LOG_ERROR("failed to get file size");
    return false;
    }
    StrInitStack(syserr, SYS_ERROR_STR_MAX_LENGTH, {
    SysStrError(errno, &syserr);
    LOG_ERROR("Failed to get localtime : {}", syserr);
    });
    LOG_SYS_ERROR("Failed to get localtime");
    size n = vsnprintf(NULL, 0, fmt, args);
    if (!n) {
    LOG_ERROR("invalid size of final string.");
    return NULL;
    }
    
    if (!is_valid_base(config->base)) {
    LOG_ERROR("Invalid base: {}", config->base);
    return NULL;
    }
    
    if (!is_valid_base(config->base)) {
    LOG_ERROR("Invalid base: {}", config->base);
    return NULL;
    }
    
    if (config->precision > 17) {
    LOG_ERROR("Precision {} exceeds maximum (17)", config->precision);
    return NULL;
    }
    
    if (!value) {
    LOG_ERROR("NULL output pointer");
    return false;
    }
    u8 base = config->base;
    if (base != 0 && !is_valid_base(base)) {
    LOG_ERROR("Invalid base: {}", base);
    return false;
    }
    
    if (pos >= str->length) {
    LOG_ERROR("Empty string");
    return false;
    }
    if (IS_SPACE(str->data[pos]))
    break;
    LOG_ERROR("Invalid digit for base {}: {c}", base, str->data[pos]);
    return false;
    }
    // Check overflow
    if (result > (UINT64_MAX - digit) / base) {
    LOG_ERROR("Overflow");
    return false;
    }
    
    if (config->strict && pos < str->length) {
    LOG_ERROR("Extra characters after number");
    return false;
    }
    
    if (!have_digits) {
    LOG_ERROR("No valid digits found");
    return false;
    }
    
    if (!value) {
    LOG_ERROR("NULL output pointer");
    return false;
    }
    
    if (pos >= str->length) {
    LOG_ERROR("Empty string");
    return false;
    }
    if (negative) {
    if (unsigned_value > 9223372036854775808ULL) {
    LOG_ERROR("Overflow");
    return false;
    }
    } else {
    if (unsigned_value > 9223372036854775807ULL) {
    LOG_ERROR("Overflow");
    return false;
    }
    
    if (!value) {
    LOG_ERROR("NULL output pointer");
    return false;
    }
    
    if (pos >= str->length) {
    LOG_ERROR("Empty string");
    return false;
    }
    
    if (!have_exp_digits) {
    LOG_ERROR("Missing exponent digits");
    return false;
    }
    
    if (config->strict && pos < str->length) {
    LOG_ERROR("Extra characters after number");
    return false;
    }
    
    if (!have_digits) {
    LOG_ERROR("No valid digits found");
    return false;
    }
    void deinit_list(GenericList *list, u64 item_size) {
    if (!list || !item_size) {
    LOG_ERROR("invalid arguments");
    return;
    }
    // starting of an object
    if (StrIterPeek(&si) != '{') {
    LOG_ERROR("Invalid object start. Expected '{'.");
    return saved_si;
    }
    if (expect_comma) {
    if (StrIterPeek(&si) != ',') {
    LOG_ERROR(
    "Expected ',' between key/value pairs in object. Invalid "
    "JSON object."
    read_si = JReadString(si, &key);
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to read string key in object. Invalid JSON");
    StrDeinit(&key);
    return saved_si;
    
    if (StrIterPeek(&si) != ':') {
    LOG_ERROR("Expected ':' after key string. Failed to read JSON");
    StrDeinit(&key);
    return saved_si;
    // if still no advancement in read position
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to parse value. Invalid JSON.");
    StrDeinit(&key);
    return saved_si;
    char c = StrIterPeek(&si);
    if (c != '}') {
    LOG_ERROR("Expected end of object '}' but found '{c}'", c);
    return saved_si;
    }
    // starting of an object
    if (StrIterPeek(&si) != '[') {
    LOG_ERROR("Invalid array start. Expected '['.");
    return saved_si;
    }
    if (expect_comma) {
    if (StrIterPeek(&si) != ',') {
    LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");
    return saved_si;
    }
    // if no advancement in read position
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to parse value. Invalid JSON.");
    return saved_si;
    }
    // end of array
    if (StrIterPeek(&si) != ']') {
    LOG_ERROR("Invalid end of array. Expected ']'.");
    return saved_si;
    }
    
    if (!str) {
    LOG_ERROR("Invalid str object to read into.");
    return si;
    }
    StrIterNext(&si);
    if (!StrIterRemainingLength(&si)) {
    LOG_ERROR("Unexpected end of string.");
    StrClear(str);
    return saved_si;
    // espaced unicode sequence
    case 'u' :
    LOG_ERROR(
    "No unicode support '{.6}'. Unicode sequence will be skipped.",
    LVAL(si.data + si.pos - 1)
    
    default :
    LOG_ERROR("Invalid JSON object key string.");
    StrClear(str);
    return saved_si;
    
    if (!num) {
    LOG_ERROR("Invalid number object.");
    return si;
    }
    case 'e' :
    if (has_exp) {
    LOG_ERROR("Invalid number. Multiple exponent indicators.");
    StrDeinit(&ns);
    return saved_si;
    case '.' :
    if (is_flt) {
    LOG_ERROR("Invalid number. Multiple decimal indicators.");
    StrDeinit(&ns);
    return saved_si;
    // +/- can only appear after an exponent
    if (!has_exp) {
    LOG_ERROR(
    "Invalid number. Exponent sign indicators '+' or '-' "
    "must appear after exponent 'E' or 'e' indicator."
    }
    if (has_exp_plus_minus) {
    LOG_ERROR(
    "Invalid number. Multiple '+' or '-' in Number. "
    "Expected only once after 'e' or 'E'."
    
    if (!ns.length) {
    LOG_ERROR("Failed to parse number. '{.8}'", LVAL(saved_si.data + saved_si.pos));
    StrDeinit(&ns);
    return saved_si;
    }
    if (end == ns.data) {
    LOG_ERROR("Failed to convert string to number.");
    StrDeinit(&ns);
    return saved_si;
    
    if (!val) {
    LOG_ERROR("Invalid pointer to integer. Don't know where to store.");
    return si;
    }
    
    if (si.pos == saved_si.pos) {
    LOG_ERROR("Failed to parse integer number.");
    return saved_si;
    }
    
    if (num.is_float) {
    LOG_ERROR("Failed to parse integer. Got floating point value.");
    return saved_si;
    }
    
    if (!val) {
    LOG_ERROR("Invalid pointer to float. Don't know where to store.");
    return si;
    }
    
    if (si.pos == saved_si.pos) {
    LOG_ERROR("Failed to parse floating point number");
    return saved_si;
    }
    
    if (!b) {
    LOG_ERROR("Invalid boolean pointer. Don't know where to store.");
    return si;
    }
    return si;
    }
    LOG_ERROR("Failed to read boolean value. Expected true. Invalid JSON");
    return saved_si;
    }
    return si;
    }
    LOG_ERROR("Failed to read boolean value. Expected false. Invalid JSON");
    return saved_si;
    }
    }
    
    LOG_ERROR("Failed to parse boolean value. Expected true/false. Invalid JSON");
    return saved_si;
    } else {
    return saved_si;
    } else {
    LOG_ERROR(
    "Insufficient string length to parse a boolean value. Unexpected "
    "end of input."
    
    if (!is_null) {
    LOG_ERROR("Invalid boolean pointer. Don't know where to store.");
    return si;
    }
    return si;
    }
    LOG_ERROR("Failed to read boolean value. Expected null. Invalid JSON");
    return saved_si;
    }
    return saved_si;
    } else {
    LOG_ERROR(
    "Insufficient string length to parse a boolean value. Unexpected "
    "end of input."
    
    if (si.pos == before_si.pos) {
    LOG_ERROR(
    "Failed to read boolean value. Expected true/false. Invalid "
    "JSON."
    
    if (si.pos == before_si.pos) {
    LOG_ERROR(
    "Failed to read boolean value. Expected true/false. Invalid "
    "JSON."
    
    if (si.pos == before_si.pos) {
    LOG_ERROR("Failed to read string value. Expected string. Invalid JSON.");
    return saved_si;
    }
    
    if (si.pos == before_si.pos) {
    LOG_ERROR("Failed to read number value. Expected a number. Invalid JSON.");
    return saved_si;
    }
    
    if (si.pos == before_si.pos) {
    LOG_ERROR("Failed to read object. Expected an object. Invalid JSON.");
    return saved_si;
    }
    
    if (si.pos == before_si.pos) {
    LOG_ERROR("Failed to read array. Expected an array. Invalid JSON.");
    return saved_si;
    }
    }
    
    LOG_ERROR("Failed to read value. Invalid JSON");
    return si;
    }
    DWORD len = GetModuleFileNameA(NULL, buffer, MAX_PATH);
    if (len == 0 || len >= MAX_PATH) {
    LOG_ERROR("Failed to get executable path or buffer too small");
    return NULL;
    }
    void ProjectDeinit(Project *p) {
    if (!p) {
    LOG_ERROR("Invalid project object. Invalid arguments");
    abort();
    }
    Scope(&file_contents, StrDeinit, {
    if (!ReadCompleteFile(file_path.data, &file_contents.data, &file_contents.length, &file_contents.capacity)) {
    LOG_ERROR("Failed to read \"{}\" source file.", file_path.data);
    continue;
    }
    
    if (!e.name.length) {
    LOG_ERROR("Invalid enum entry in 'entries' array. Entry without name.");
    abort();
    }
    
    if (to_from_str && !e.str.length) {
    LOG_ERROR("to_from_str is set to true but str value not provided for enum {}", e.name);
    abort();
    }
    "{} {}FromZstr(const char* zstr) {{\n"
    "    if(!zstr) {{\n"
    "        LOG_ERROR(\"Invalid string provided. Cannot convert to enum.\");\n"
    "        return {};\n"
    "    }}\n";
    FILE *elf = fopen(argv[1], "rb");
    if (!elf) {
    LOG_ERROR("Failed to open file for reading.");
    return 1;
    }
    VecDeinit(&file);
    } else {
    LOG_ERROR("Failed to read file");
    }
    return 0;
    
    if (idx > 4) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (idx >= 5) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    // loop will automatically terminate
    if (idx < 10) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (idx > 4) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (idx < 12) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (idx >= s.length) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (idx > 3) {
    LOG_ERROR("Should've terminated");
    StrDeinit(&s);
    return false;
    
    if (iteration_count > 2) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx > 2) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx < 4) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx > 3) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx < 5) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx > vec.length) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    
    if (idx > 2) {
    LOG_ERROR("Should've terminated");
    VecDeinit(&vec);
    return false;
    /* starting of an object */                                                                                    \
    if (StrIterPeek(&si) != '[') {                                                                                 \
    LOG_ERROR("Invalid array start. Expected '['.");                                                           \
    si = saved_si;                                                                                             \
    break;                                                                                                     \
    if (expect_comma) {                                                                                        \
    if (StrIterPeek(&si) != ',') {                                                                         \
    LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");                            \
    failed = true;                                                                                     \
    si     = saved_si;                                                                                 \
    /* if still no advancement in read position */                                                         \
    if (read_si.pos == si.pos) {                                                                           \
    LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
    StrDeinit(&key);                                                                                   \
    failed = true;                                                                                     \
    if (!failed) {                                                                                                 \
    if (StrIterPeek(&si) != ']') {                                                                             \
    LOG_ERROR("Invalid end of array. Expected ']'.");                                                      \
    failed = true;                                                                                         \
    si     = saved_si;                                                                                     \
    /* starting of an object */                                                                                    \
    if (StrIterPeek(&si) != '{') {                                                                                 \
    LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
    si = saved_si;                                                                                             \
    break;                                                                                                     \
    if (expect_comma) {                                                                                        \
    if (StrIterPeek(&si) != ',') {                                                                         \
    LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
    failed = true;                                                                                     \
    si     = saved_si;                                                                                 \
    read_si = JReadString(si, &key);                                                                           \
    if (read_si.pos == si.pos) {                                                                               \
    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
    StrDeinit(&key);                                                                                       \
    failed = true;                                                                                         \
    \
    if (StrIterPeek(&si) != ':') {                                                                             \
    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
    StrDeinit(&key);                                                                                       \
    failed = true;                                                                                         \
    /* if still no advancement in read position */                                                         \
    if (read_si.pos == si.pos) {                                                                           \
    LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
    StrDeinit(&key);                                                                                   \
    failed = true;                                                                                     \
    char c = StrIterPeek(&si);                                                                                 \
    if (c != '}') {                                                                                            \
    LOG_ERROR("Expected end of object '}' but found '{c}'", c);                                            \
    failed = true;                                                                                         \
    si     = saved_si;                                                                                     \

Share :

Related Posts

SysSetAbortCallback

SysSetAbortCallback Description Set a custom callback function for SysAbort. If no callback is set, SysAbort will call the standard abort() function.

Read More

WriteFmt

WriteFmt Description Write formatted output to the standard output stream (stdout). This is a convenience macro calling FWriteFmt with stdout.

Read More

StrReadFmt

StrReadFmt Description Parse input string according to format string with rust-style placeholders, extracting values into provided arguments. This is a macro wrapper around StrReadFmtInternal.

Read More