68
73
CSL.log(self, CSLog::Error, " ");
69
74
CSL.log(self, CSLog::Error, getMessage());
70
75
CSL.eol(self, CSLog::Error);
76
#ifdef DUMP_STACK_TRACE
71
77
CSL.log(self, CSLog::Error, getStackTrace());
81
88
CSL.log(self, CSLog::Error, " ");
82
89
CSL.log(self, CSLog::Error, getMessage());
83
90
CSL.eol(self, CSLog::Error);
91
#ifdef DUMP_STACK_TRACE
84
92
CSL.log(self, CSLog::Error, getStackTrace());
97
void CSException::initException_va(const char *func, const char *file, int line, int err, const char *fmt, va_list ap)
100
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
103
vsprintf(iMessage, fmt, ap);
106
len = vsnprintf(iMessage, CS_EXC_MESSAGE_SIZE-1, fmt, ap);
107
if (len > CS_EXC_MESSAGE_SIZE-1)
108
len = CS_EXC_MESSAGE_SIZE-1;
113
void CSException::initExceptionf(const char *func, const char *file, int line, int err, const char *fmt, ...)
118
initException_va(func, file, line, err, fmt, ap);
88
122
void CSException::initException(const char *func, const char *file, int line, int err, const char *message)
90
124
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
108
142
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
109
143
iErrorCode = CS_ERR_ASSERTION;
110
cs_strcpy(CS_EXC_MESSAGE_SIZE, iMessage, message);
144
cs_strcpy(CS_EXC_MESSAGE_SIZE, iMessage, "Assertion failed: ");
145
cs_strcat(CS_EXC_MESSAGE_SIZE, iMessage, message);
113
148
void CSException::getCoreError(uint32_t size, char *buffer, int err)
146
181
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
147
182
iErrorCode = err;
148
183
getCoreError(CS_EXC_MESSAGE_SIZE, iMessage, err);
149
cs_replace_string(CS_EXC_MESSAGE_SIZE, iMessage, '%', item);
184
cs_replace_string(CS_EXC_MESSAGE_SIZE, iMessage, "%s", item);
152
187
void CSException::initOSError(const char *func, const char *file, int line, int err)
257
e.initException(func, file, line, err,message);
292
e.initException(func, file, line, err, message);
258
293
e.log(NULL, "*** Uncaught error");
264
299
throwException(func, file, line, err, message, NULL);
302
void CSException::throwExceptionf(const char *func, const char *file, int line, int err, const char *fmt, ...)
308
if ((self = CSThread::getSelf())) {
309
self->myException.initException_va(func, file, line, err, fmt, ap);
311
self->myException.setStackTrace(self, NULL);
312
self->throwException();
317
e.initException_va(func, file, line, err, fmt, ap);
319
e.log(NULL, "*** Uncaught error");
267
323
void CSException::throwAssertion(const char *func, const char *file, int line, const char *message)
271
327
if ((self = CSThread::getSelf())) {
272
328
self->myException.initAssertion(func, file, line, message);
273
329
self->myException.setStackTrace(self);
330
/* Not sure why we log the excpetion down here?!
274
331
self->logException();
275
333
self->throwException();
412
470
void CSException::throwLastError(const char *func, const char *file, int line)
414
472
#ifdef OS_WINDOWS
415
throwOSError(func, file, line, (int) getLastError());
473
throwOSError(func, file, line, (int) GetLastError());
417
475
throwOSError(func, file, line, (int) errno);