LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
Status and error handling

Canonical status codes and failure callback hooks. More...

Collaboration diagram for Status and error handling:

Modules

 Status codes
 Well-defined error and success codes used by LibJuno.
 

Macros

#define JUNO_FAIL_MESSAGE_LEN   256
 Recommended maximum length for failure messages.
 
#define JUNO_FAIL(tStatus, pfcnFailureHandler, pvFailureUserData, pcMessage)   if(pfcnFailureHandler){pfcnFailureHandler(tStatus, pcMessage, pvFailureUserData);}
 Invoke a failure handler if provided.
 
#define JUNO_FAIL_MODULE(tStatus, ptMod, pcMessage)   if(ptMod && ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER){ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_USER_DATA);}
 Invoke a module instance's failure handler if available.
 
#define JUNO_FAIL_ROOT(tStatus, ptMod, pcMessage)   if(ptMod && ptMod->JUNO_FAILURE_HANDLER){ptMod->JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_FAILURE_USER_DATA);}
 Invoke a module root's failure handler if available.
 

Typedefs

typedef int32_t JUNO_STATUS_T
 Canonical status type for LibJuno functions.
 
typedef void JUNO_USER_DATA_T
 Opaque user data type for failure callbacks.
 
typedef void(* JUNO_FAILURE_HANDLER_T) (JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
 Failure handler callback signature.
 

Detailed Description

Canonical status codes and failure callback hooks.

LibJuno uses a single 32-bit integer type for status propagation. Zero indicates success; non-zero values indicate specific failure conditions enumerated by the constants in this module. Optional failure callbacks let applications log or collect diagnostics without affecting control flow.

Macro Definition Documentation

◆ JUNO_FAIL

#define JUNO_FAIL (   tStatus,
  pfcnFailureHandler,
  pvFailureUserData,
  pcMessage 
)    if(pfcnFailureHandler){pfcnFailureHandler(tStatus, pcMessage, pvFailureUserData);}

Invoke a failure handler if provided.

Parameters
tStatusStatus value to report.
pfcnFailureHandlerFailure handler function pointer (nullable).
pvFailureUserDataOpaque user data pointer passed to the handler.
pcMessageOptional message describing the failure.
Note
This macro does not alter control flow; callers should still return or handle the error as appropriate.

◆ JUNO_FAIL_MESSAGE_LEN

#define JUNO_FAIL_MESSAGE_LEN   256

Recommended maximum length for failure messages.

◆ JUNO_FAIL_MODULE

#define JUNO_FAIL_MODULE (   tStatus,
  ptMod,
  pcMessage 
)    if(ptMod && ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER){ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_MODULE_SUPER.JUNO_FAILURE_USER_DATA);}

Invoke a module instance's failure handler if available.

Parameters
tStatusStatus value to report.
ptModPointer to a module instance (may be NULL).
pcMessageOptional message describing the failure.
Warning
This macro expects the pointed-to object to expose a JUNO_MODULE_SUPER member with JUNO_FAILURE_HANDLER and JUNO_FAILURE_USER_DATA fields as defined by the module system. Use only with LibJuno module types.

◆ JUNO_FAIL_ROOT

#define JUNO_FAIL_ROOT (   tStatus,
  ptMod,
  pcMessage 
)    if(ptMod && ptMod->JUNO_FAILURE_HANDLER){ptMod->JUNO_FAILURE_HANDLER(tStatus, pcMessage, ptMod->JUNO_FAILURE_USER_DATA);}

Invoke a module root's failure handler if available.

Parameters
tStatusStatus value to report.
ptModPointer to a module root (may be NULL).
pcMessageOptional message describing the failure.

Typedef Documentation

◆ JUNO_FAILURE_HANDLER_T

typedef void(* JUNO_FAILURE_HANDLER_T) (JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)

Failure handler callback signature.

Parameters
tStatusStatus code for the failure condition.
pcCustomMessageOptional, human-readable message with context (may be NULL).
pvUserDataOpaque user data pointer supplied by the caller (may be NULL).

◆ JUNO_STATUS_T

typedef int32_t JUNO_STATUS_T

Canonical status type for LibJuno functions.

◆ JUNO_USER_DATA_T

typedef void JUNO_USER_DATA_T

Opaque user data type for failure callbacks.