theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_C_API

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

+ Collaboration diagram for MkExceptionC_C_API:

Functions

bool MkExceptionCheck (MK_EXP exception)
 Checks if Exception is of type MkExceptionC and returns MK_YES or MK_NO
 
void MkExceptionRaise (MK_MNG const expobj, MK_STRN const callfunc, MK_I32 const callline)
 convert an MkErrorC into a Target-Programming-Language (TPL) exception …
 
MK_ERR MkExceptionCatch (MK_MNG const expobj, MK_EXP const exception, MK_STRN const callfunc)
 convert an Target-Programming-Language (TPL) exception into an MkErrorC
 

Detailed Description

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

Function Documentation

◆ MkExceptionCatch()

MK_ERR MkExceptionCatch ( MK_MNG const expobj,
MK_EXP const exception,
MK_STRN const callfunc )

convert an Target-Programming-Language (TPL) exception into an MkErrorC

Parameters
[in]expobjThe LibMsgqueObject used to personalize the exception/error (will be validated first)
[in]exceptionthe exception object from C, if MK_NULL the global exception object is used
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, MK_NULL = resolve-own-name)
Returns
the MkErrorC created with data from exception

◆ MkExceptionCheck()

bool MkExceptionCheck ( MK_EXP exception)

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

◆ MkExceptionRaise()

void MkExceptionRaise ( MK_MNG const expobj,
MK_STRN const callfunc,
MK_I32 const callline )

convert an MkErrorC into a Target-Programming-Language (TPL) exception …

Parameters
[in]expobjThe LibMsgqueObject used to personalize the exception/error (will be validated first)
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, MK_NULL = resolve-own-name)
[in]calllinethe number of the line the call take place (e.g. LINE)