theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_cc.cc
Go to the documentation of this file.
1
9/* LABEL-NO */
10
11/*****************************************************************************/
12/* */
13/* context */
14/* */
15/*****************************************************************************/
16
17#include "private_cc.hh"
18#include <iostream>
19#include <sstream>
20
21/*
22#define refLOG(t, p) \
23 printV("%s: hdl=%p, refCount=%i, DEFAULT=%c\n", t, p, \
24 (MkObjCheck(p)?p->obj.refCount:-1), (p==&MkErrorTLS?'Y':'N'))
25*/
26
27namespace ccmkkernel {
28
33
38
39 MkExceptionC::MkExceptionC(MK_ERR const err, MK_STRN const caller, MK_I32 const line) {
40 MK_ERR const def = MkErrorFORMAT_1M(err);
41 MkRtSetup_XN(def);
42 hdl = (err && err != def ? err : MkErrorDup(def));
43
45 MkErrorReset(def,caller,line,false);
46 }
47
48 MkExceptionC::MkExceptionC(MK_MNGN const mng, MK_STRN const caller, MK_I32 const line) {
49 MK_ERR const def = MkErrorFORMAT_1M(mng);
50 MkRtSetup_XN(def);
51 hdl = MkErrorDup(def);
52
54 MkErrorReset(def,caller,line,false);
55 }
56
57 void MkExceptionC::Raise (MK_MNGN const mng, MK_STRN const caller, MK_I32 const line)
58 {
59 throw MkExceptionC(mng,caller,line);
60 }
61
62 MK_ERR MkExceptionC::Catch (MK_MNGN const mng, const std::exception * const ex, MK_STRN const caller)
63 {
64 std::stringstream ss;
65 MK_ERR err = MkErrorFORMAT_1M(mng);
66 MkRtSetup_XN(err);
67
68 auto* mqex = dynamic_cast<MkExceptionC const * const>(ex);
69 if (mqex != NULL) {
70 MkErrorSetE (err, mqex->hdl);
71 return err ;
72 }
73 auto* krex = dynamic_cast<MkKernelException const * const>(ex);
74 if (krex != NULL) {
75 MkErrorSetC (err, ex->what(), caller, -1);
76 MkErrorStackFormat (err, krex->func.c_str(), krex->file.c_str(), krex->line);
77 return err ;
78 }
79
80 MkErrorSetC (err, ex->what(), caller, -1);
81 return err;
82 }
83
84 MK_ERR MkExceptionC::Catch (MK_MNGN const mng, const std::string& msg, MK_STRN const caller)
85 {
86 MK_ERR err = MkErrorFORMAT_1M(mng);
87 MkRtSetup_XN(err);
88
89 MkErrorSetC (err, msg.c_str(), caller, -1);
90
91 return err;
92 }
93
94} // END - namespace "ccmkkernel"
95
MkExceptionC - The default-exception of the Programming-Language-Micro-Kernel (PLMK) …
#define MkErrorStackFormat(...)
#define MkErrorReset(...)
#define MkErrorSetC(...)
#define MkErrorSetE(...)
#define MkErrorFORMAT_1M(m)
#define MkErrorDup(...)
static void Raise(MK_MNGN const expobj, MK_STRN const callfunc=__builtin_FUNCTION(), MK_I32 const callline=__builtin_LINE())
convert an MkErrorC into a Target-Programming-Language (TPL) exception … → C-API: libmkkernel::MkE...
static MK_ERR Catch(MK_MNGN const expobj, std::exception const *exception, MK_STRN const callfunc=__builtin_FUNCTION())
convert an Target-Programming-Language (TPL) exception into an MkErrorC … → C-API: libmkkernel::Mk...
MkExceptionC(MK_ERR err, MK_STRN const caller, MK_I32 const line)
constructor
MK_ERR hdl
link to the MkErrorC object
virtual ~MkExceptionC()
destructor
signed int MK_I32
4 byte integer data-type
const MK_PTRB * MK_MNGN
const - a managed object pointer, datatype will be checked at runtime
const MK_STRB * MK_STRN
constant string pointer data-type
#define MkRefDecr_X(x)
#define MkRefIncr_1X(x)
#define MkRtSetup_XN(x)
#define MkRtSetup_X(x)
namespace for the CcMkKernel "C++"-API
The data-type to store and handle the error-condition …