theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_RB_API

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

+ Collaboration diagram for MkExceptionC_RB_API:

Functions

void rbmkkernel_MkExceptionC_Raise (OT_Prefix_ARGS MK_MNGN const expobj, MK_STRN const doc, MK_STRN const callfunc, MK_I32 callline)
 convert an MkErrorC into a Target-Programming-Language (TPL) exception …
 
MK_ERR rbmkkernel_MkExceptionC_Catch (OT_Prefix_ARGS MK_MNG const expobj, MK_EXP exception, MK_STRN const callfunc, MK_STRN const stop)
 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

◆ rbmkkernel_MkExceptionC_Catch()

MK_ERR rbmkkernel_MkExceptionC_Catch ( OT_Prefix_ARGS MK_MNG const expobj,
MK_EXP exception,
MK_STRN const callfunc,
MK_STRN const stop )

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 Ruby, if nil the global exception object is used
[in]callfunca user-defined postfix to identify the calling-function or the environment (default = name-of-function, nil = resolve-own-name)
Returns
the MkErrorC created with data from exception
Parameters
[in]stopEnd of stack-trace

Definition at line 66 of file MkExceptionC_rb.c.

72 {
73 if (exception == NULL) exception = (MK_EXP) rb_errinfo();
74 VALUE ex = (VALUE) exception;
75 MK_ERR err = MkErrorFORMAT_1M(expobj);
76 if (rb_obj_is_kind_of(ex, MK(MkExceptionC)) == Qtrue) {
77 static ID id_mkerr = 0;
78 if (!id_mkerr) id_mkerr = rb_intern("mkerr");
79 MK_ERR newerr = VAL2ERR(rb_funcallv(ex,id_mkerr,0,NULL));
80 MkErrorSetE (err, newerr);
81 rb_set_errinfo(Qnil);
82 } else if (rb_obj_is_kind_of(ex, rb_eStandardError) == Qtrue) {
83
84 VALUE argv[4];
85 argv[0] = OT_TMP_ERR_OBJ(err);
86 argv[1] = ex;
87 argv[2] = STRN2VAL(callfunc);
88 argv[3] = stop == NULL ? Qnil : STRN2VAL(stop);
89
90 rb_funcallv(MK(MkExceptionC), MK(id_Catch), 4, argv);
91 rb_set_errinfo(Qnil);
92 } else if (rb_obj_is_kind_of(ex, rb_eSystemExit) == Qtrue) {
93 // exit in an callback
94 MkErrorSetEXIT(err,callfunc);
95 } else {
96 MkLogV_2X(err,"WARNING: re-raise exception (long-jump in code) → %s\n",
97 VAL2STRN(rb_inspect(ex))
98 );
99 rb_exc_raise(ex);
100 }
101 return err;
102}
#define MK(n)
#define VAL2ERR(val)
#define VAL2STRN(val)
#define OT_TMP_ERR_OBJ(val)
#define STRN2VAL(nat)
#define MkErrorSetE(...)
#define MkErrorSetEXIT(...)
#define MkErrorFORMAT_1M(m)
MK_PTRB const * MK_EXP
exception object pointer
#define MkLogV_2X(x, printfmt,...)
The data-type to store and handle the error-condition …

◆ rbmkkernel_MkExceptionC_Raise()

void rbmkkernel_MkExceptionC_Raise ( OT_Prefix_ARGS MK_MNGN const expobj,
MK_STRN const doc,
MK_STRN const callfunc,
MK_I32 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, nil = resolve-own-name)
[in]calllinethe number of the line the call take place (e.g. LINE)
[in]docdocumentation string

Definition at line 43 of file MkExceptionC_rb.c.

49 {
50 MK_ERR err = MkErrorFORMAT_1M(expobj);
51 MkErrorStackFormat(err,doc,callfunc,callline);
52 MK(Get_Call_Stack)(MK_RT_CALL err, 0);
53 MK_ERR newerr = MkErrCheck(expobj) && expobj != err ? (MK_ERR)expobj : MkErrorDup(err);
54 //VALUE errO = Data_Wrap_Struct(MK(MkExceptionC), NULL, MK(MkExceptionC_Delete), newerr);
55 VALUE args[2];
56 args[0] = OT_TMP_ERR_OBJ(newerr);
57 args[1] = STRN2VAL(MkErrorGetTextI(newerr));
58 VALUE errO = rb_class_new_instance(2,args,MK(MkExceptionC));
59 MkErrorReset_1(err);
60 rb_exc_raise(errO);
62}
struct MkErrorS * MK_ERR
class-shortcut for struct MkErrorS *, all shortcut using the XX_YYY syntax (only for public API) …
static bool MkErrCheck(MK_MNGN mng)
check MkErrorS -> MkObjectS::signature …
#define MkErrorGetTextI(e)
get the MkErrorS::text …
#define MkErrorReset_1(err)
#define MkErrorStackFormat(...)
#define MkErrorDup(...)
#define MK_UNREACHABLE
#define MK_RT_CALL