theKernel 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard - theLib
c - tcl - atl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
MkErrorC_C_API

MkErrorC - the class known as err or error is used to create and manage an error message … More...

+ Collaboration diagram for MkErrorC_C_API:

Topics

 MkErrExtC
 MkErrExtS - extend the MkErrorC with a library specific feature …
 
 MkErrorPanicC
 signal-slot for panic on error
 
 MkErrorIgnoreC
 signal-slot for ignore on error
 
 MkErrorPrintC
 signal-slot for print on error
 
 MkErrorDefaultC
 signal-slot for raise an error
 
 MkErrorC_Class_C_API
 MkErrorC - define the class …
 
 MkErrorC_TOR_C_API
 MkErrorC - various functions to 'create' and 'delete' a MkErrorS
 
 MkErrorC_System_C_API
 MkErrorC - various functions to raise a 'System' messagen on MkErrorS
 
 MkErrorC_Signal_C_API
 MkErrorC - various functions to set and check a 'signal' on a MkErrorS
 
 MkErrorC_Get_C_API
 MkErrorC - various functions to 'get' data out of a MkErrorS
 
 MkErrorC_Raise_C_API
 MkErrorC - various functions to 'raise' a MkErrorS
 
 MkErrorC_Misc_C_API
 MkErrorC - various functions to 'work' on a MkErrorS
 

Data Structures

struct  MkErrorS
 The data-type to store and handle the error-conditionMore...
 

Macros

#define MkDbgErr_2(err, col)
 
#define MkDbgErr(err)
 

Detailed Description

MkErrorC - the class known as err or error is used to create and manage an error message …

An error is a singleton object per thread created at startup and is located at MkRuntimeRLS using the datatype MkErrorC.

‍As error-indicator the enum MkErrorE is used.

The MkErrorC is used to collect all data needed to handle an error and provide global ressources required to process and report the error.

The MkErrorC is also used to integrate the error-handling from libmkkernel into the error-handling-code of the target C.

Example from Filter6.c use MqContextErrorCatch to convert a C error into a libmkkernel error

int
main (
  const int argc,
  MK_STRN argv[]
)
{
  AllRtSetup_NULL;

  // define the new type
  Filter6TT = MkTypeDup2(MqContextC_TT,"Filter6");
  Filter6TT->objsize = sizeof(struct FilterCtxS);
  Filter6T->fHelp = FilterHelp;

  // create the factory
  MQ_FCT mqfct = MqFactoryAdd(MK_ERROR_PANIC, Filter6Factory, NULL,NULL,NULL,NULL,NULL,NULL,NULL,"Filter6");
  MQ_CTX mqctx = NULL;

#ifdef BUG1
  // for BUG testing in 'trans2-2-T1aE-...'
  MqFactoryInitial(mqfct);
#endif

  // parse the command-line
  MK_BFL args = MkBufferListCreateVC (argc, argv);

  // search for option "--retryCnt"
  MkBufferListCheckOptionI32_E (args, "--retryCnt", 3, true, &retryCnt);

  // create the filter
  MqFactoryNew_E (mqfct, NULL, &mqctx);

  // create the link
  MqLinkCreate_E (mqctx, args);

  // start event-loop and wait forever
  MqProcessEvent_E (mqctx, MQ_WAIT_FOREVER, MK_TIMEOUT_USER);

  // finish and exit
error:
  MkBufferListDelete(args);
  MqExit_1 (mqctx);
}

MkExceptionC

MkExceptionC - The default-exception of the Programming-Language-Micro-Kernel (PLMK)

The Programming-Language-Micro-Kernel (PLMK) provide with MkErrorC a complete error-handling with focus to support the "C" Programming-Language. The support include catch, raise, signal and attributes. In addition every Target-Programming-Language (TPL) add their own error-handling and the purpose of MkExceptionC is to integrate the MkErrorC into the Target-Programming-Language (TPL).

The default-exception MkExceptionC is used to connect the MkErrorC with the Target-Programming-Language (TPL) error-object.

The implementation of an exception depends heavily on the Target-Programming-Language (TPL), starting with no exception at all, for example. C, an exception as a class object, or as an exception as a global attribute.

Attention

ExceptionCheck

Checks if Exception is of type MkExceptionC and returns MK_YES or MK_NO

Attention
This is just a placeholder and have to be implemented in the Target-Programming-Language (TPL).

Example: test case to check KILL and RECOVER feature, check on MkExceptionC

    MK_BUF VAL = MqReadBUF_e(mqctx);
    clmqctx = MqContextCreate (ClientTT, NULL);
    MqConfigSetPrefix(clmqctx,"cl");
    MqConfigSetPostfix(clmqctx,"-1");
    MkErrorCheck (ClientCreateParent2( MK_RT_CALL mqctx, clmqctx));
    MK_I32 PID=0;
    MqSend_E(clmqctx, "W", "GPID@I", &PID);
    MkSysKill_E(MkOBJ(mqctx),PID,9);
    MK_I32 RET=0;
    for (int i=1; i<=3; i++) {
      if (MkErrorCheckI(MqSend(clmqctx, "W", "ECOI:U@I", VAL, &RET))) {
        if (MkErrorIsSOCKET_0E()) {
          MkErrorReset_1X(clmqctx);
          MqLinkConnect(clmqctx);
          continue;
        } else {
          goto error;
        }
      }
      break;
    }
    MqSendSTART_E(mqctx);
    MqSendI32_E (mqctx, RET);
Returns
the result of the check, MK_YES or MK_NO
Parameters
[in]exceptionthe exception object from C, if MK_NULL the global exception object is used

Macro Definition Documentation

◆ MkDbgErr

#define MkDbgErr ( err)
Value:
MkDbgErr_2(err,MK_COLOR_WHITE)
#define MkDbgErr_2(err, col)

Definition at line 9698 of file LibMkKernel_mk.h.

◆ MkDbgErr_2

#define MkDbgErr_2 ( err,
col )
Value:
mk_dbg_color_ln(col,"MkDbgErr[%p]: check<%d>, mkrt<%s>, isLocal<%d>, format_of_error<%p>", \
err, MkErrCheck(err), MkDbgRtChkX(err), MkOBJ(err)->obj_protect.isLocal, err->format_of_error)
static bool MkErrCheck(MK_MNGN mng)
check MkErrorS -> MkObjectS::signature …
#define MkOBJ(x)
cast a known-object into an MkObjectS pointer
#define MkDbgRtChkX(x)

Definition at line 9695 of file LibMkKernel_mk.h.

9695#define MkDbgErr_2(err,col) \
9696 mk_dbg_color_ln(col,"MkDbgErr[%p]: check<%d>, mkrt<%s>, isLocal<%d>, format_of_error<%p>", \
9697 err, MkErrCheck(err), MkDbgRtChkX(err), MkOBJ(err)->obj_protect.isLocal, err->format_of_error)