theKernel 10.0
Loading...
Searching...
No Matches
MkExceptionC_cc.hh
Go to the documentation of this file.
1
9/* LABEL-NO */
10
11#pragma once
12
13#include <exception>
14#include <stdexcept>
15
16#define InstHdlIsNullError() throw HdlIsNullError(ToNativeNameOfClass())
17#define ClassHdlIsNullError(cls) throw HdlIsNullError(#cls)
18
19namespace ccmkkernel {
20
23 class MkExceptionC : public std::exception
24 {
25 friend class MkErrorC;
26
32
33 protected:
36
38 MkExceptionC (MK_ERR err, MK_STRN const caller, MK_I32 const line);
40 MkExceptionC (MK_MNGN const mng, MK_STRN const caller, MK_I32 const line);
41
42 public:
43
45 MkExceptionC(const MkExceptionC& e);
46
48 virtual ~MkExceptionC() throw();
49
55 inline virtual MK_STRN what() const throw() {
56 return MkBUF_R(&hdl->text).storage.first.C;
57 }
58
60 inline void Log(
61 MK_DBG debug = 0,
62 MK_STRN callfunc = __builtin_FUNCTION(),
63 MK_I32 lvl = 0
64 ) const {
66 MkErrorLog(hdl, NULL, debug, callfunc, lvl);
67 }
68
69 public:
70
72 static void Raise (
73 MK_MNGN const expobj,
74 MK_STRN const callfunc = __builtin_FUNCTION(),
75 MK_I32 const callline = __builtin_LINE()
76 );
77
79 static MK_ERR Catch (
80 MK_MNGN const expobj,
81 std::exception const *exception,
82 MK_STRN const callfunc = __builtin_FUNCTION()
83 );
85 static inline MK_ERR Catch (
86 MK_MNGN const expobj,
87 std::exception const &exception,
88 MK_STRN const callfunc = __builtin_FUNCTION()
89 ) {
90 return Catch(expobj, &exception, callfunc);
91 }
93 static MK_ERR Catch (
94 MK_MNGN const expobj,
95 const std::string& msg,
96 MK_STRN const callfunc = __builtin_FUNCTION()
97 );
98
100 // MkExceptionC_CC_API
101 };
102
103 class MkKernelException : public std::runtime_error
104 {
105 public:
106 std::string func;
107 std::string file;
108 int line;
109 MkKernelException(const std::string& what,
110 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
111 : runtime_error(what), func(func), file(file), line(line) {}
112 };
113
116 {
117 public:
118 inline MkReferenceNullExceptionC(const std::string& what,
119 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
120 : MkKernelException("the reference of '" + what + "' is NULL", func, file, line) {}
121 };
122
125 {
126 public:
127 inline MkConstructorNullExceptionC(const std::string& what,
128 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
129 : MkKernelException("the constructor '" + what + "' has a NULL pointer", func, file, line) {}
130 };
131
134 {
135 public:
136 inline MkInitError(const std::string& what,
137 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
138 : MkKernelException("InitError: '" + what + "' constructor return 'NULL' pointer", func, file, line) {}
139 };
140
143 {
144 public:
145 inline MkInitSoftError(const std::string& what,
146 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
147 : MkKernelException("InitSoftError: '" + what + "' soft constructor return 'NULL' pointer", func, file, line) {}
148 };
149
151 {
152 public:
153 inline HdlIsNullError(const std::string& what,
154 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
155 : MkKernelException(std::string("'") + what + "' hdl is NULL", func, file, line) {}
156
157 inline HdlIsNullError(const char* what,
158 std::string func = __builtin_FUNCTION(), std::string file = __builtin_FILE(), int line = __builtin_LINE())
159 : HdlIsNullError(std::string(what), func, file, line) {}
160 };
161
162}
HdlIsNullError(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
HdlIsNullError(const char *what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
MkConstructorNullExceptionC(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
The data-type to store and handle the error-condition … → C-API: libmkkernel::MkErrorS
MkExceptionC - The default-exception of the Programming-Language-Micro-Kernel (PLMK) …
constructor return MK_NULL
MkInitError(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
soft constructor return MK_NULL
MkInitSoftError(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
MkKernelException(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
reference argument is MK_NULL
MkReferenceNullExceptionC(const std::string &what, std::string func=__builtin_FUNCTION(), std::string file=__builtin_FILE(), int line=__builtin_LINE())
#define MkBUF_R(x)
cast a known-object into an MkBufferS reference
#define MkErrorLog(...)
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...
virtual MK_STRN what() const
Returns the explanatory string.
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
void Log(MK_DBG debug=0, MK_STRN callfunc=__builtin_FUNCTION(), MK_I32 lvl=0) const
log the error to MkLogFileC (default: stderr) … → C-API: ErrorLog
MK_ERR hdl
link to the MkErrorC object
virtual ~MkExceptionC()
destructor
int MK_DBG
debug-level data-type …
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 MkRtSetup_X(x)
namespace for the CcMkKernel "C++"-API
The data-type to store and handle the error-condition …
struct MkBuffer1024S text
the error message