engine: make capacity error more specific

Signed-off-by: Ronald Caesar <github43132@proton.me>
This commit is contained in:
Ronald Caesar
2026-06-17 02:59:31 -04:00
parent a69df0101a
commit 2e7240e9d4
2 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -20,6 +20,7 @@ extern "C"
BAL_SUCCESS = 0,
BAL_ERROR_INVALID_ARGUMENT = -1,
BAL_ERROR_ALLOCATION_FAILED = -2,
BAL_ERROR_STRUCT_CORRUPTED = -3,
// Memory and Translation Errors
@@ -62,7 +63,7 @@ extern "C"
BAL_ERROR_BRANCH_OFFSET_OVERFLOW = -202,
/// The provided buffer capacity is too large and would cause an integer overflow.
BAL_ERROR_INVALID_CAPACITY = -203,
BAL_ERROR_CAPACITY_TOO_BIG = -203,
} bal_error_t;
/// Converts the enum into a readable string for error handling.
+4 -2
View File
@@ -11,8 +11,10 @@ bal_error_to_string(const bal_error_t error)
return "function argument is NULL or invalid";
case BAL_ERROR_ALLOCATION_FAILED:
return "failed to allocate memory";
case BAL_ERROR_STRUCT_CORRUPTED:
return "struct integrity check failed";
// --- Memory & Translation ---
// --- Memory & Translation ---
case BAL_ERROR_MEMORY_ALIGNMENT:
return "buffer is not aligned to the required memory alignment";
case BAL_ERROR_MEMORY_FAULT:
@@ -39,7 +41,7 @@ bal_error_to_string(const bal_error_t error)
return "decoded register type mismatch";
case BAL_ERROR_BRANCH_OFFSET_OVERFLOW:
return "relative branch offset exceeds displacement limit";
case BAL_ERROR_INVALID_CAPACITY:
case BAL_ERROR_CAPACITY_TOO_BIG:
return "buffer capacity is too large and would cause integer overflow";
default: