CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Error Codes

Enumerations

enum  CX_ERROR {
  CX_Success = 0 , CX_Unspecified , CX_InvalidArgument , CX_AccessDenied ,
  CX_FileNotFound , CX_AlreadyExists , CX_IsDirectory , CX_ReadOnly ,
  CX_Range
}
 

Functions

const char * cxErrMsg (int err)
 

Variables

_Thread_local int cxerr
 

Detailed Description

Thread-local error code system for functions that cannot return error values.

The cxerr facility provides a thread-safe error reporting mechanism similar to the standard errno, but integrated into the CX framework. Functions that need to report errors but cannot return an error code (e.g., functions returning pointers or having other return value semantics) can set cxerr to indicate the reason for failure.

Key characteristics:

Typical usage pattern:

cxerr = CX_Success; // Clear error before operation
float val = strToFloat32(_S"invalid");
if (cxerr != CX_Success) {
logError(_S"Conversion failed: %"), cxErrMsg(cxerr));
}
_Thread_local int cxerr
const char * cxErrMsg(int err)
@ CX_Success
Operation completed successfully (no error)
Definition error.h:51
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392
bool strToFloat32(float32 *out, strref s, bool strict)

Functions should document when they set cxerr on failure.

Enumeration Type Documentation

◆ CX_ERROR

enum CX_ERROR

Standard CX error codes

Error codes used throughout the CX framework. Functions set cxerr to one of these values to indicate specific error conditions.

Enumerator
CX_Success 

Operation completed successfully (no error)

CX_Unspecified 

Unknown or unspecified error occurred.

CX_InvalidArgument 

Function argument is invalid or malformed.

CX_AccessDenied 

Permission denied or access not allowed.

CX_FileNotFound 

Requested file or resource does not exist.

CX_AlreadyExists 

File or resource already exists; refusing to overwrite.

CX_IsDirectory 

Attempted to treat a directory as a file.

CX_ReadOnly 

Attempted to write to read-only path or resource.

CX_Range 

Value is out of valid range.

Definition at line 50 of file error.h.

Function Documentation

◆ cxErrMsg()

const char * cxErrMsg ( int  err)

Get human-readable error message for an error code

Parameters
errError code from CX_ERROR enum
Returns
Constant string describing the error

Returns a descriptive message for the given error code. Useful for logging or displaying error information to users.

if (cxerr != CX_Success) {
printf("Error: %s\n", cxErrMsg(cxerr));
}

Variable Documentation

◆ cxerr

_Thread_local int cxerr
extern

Thread-local error code

Set by functions to indicate error conditions. Check this variable after calling functions that document cxerr usage. Always CX_Success (0) when no error occurred.