15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
19
* Original author: Paul McCullagh (H&G2JCtL)
20
20
* Continued development: Barry Leslie
73
68
CSL.log(self, CSLog::Error, " ");
74
69
CSL.log(self, CSLog::Error, getMessage());
75
70
CSL.eol(self, CSLog::Error);
76
#ifdef DUMP_STACK_TRACE
77
71
CSL.log(self, CSLog::Error, getStackTrace());
88
81
CSL.log(self, CSLog::Error, " ");
89
82
CSL.log(self, CSLog::Error, getMessage());
90
83
CSL.eol(self, CSLog::Error);
91
#ifdef DUMP_STACK_TRACE
92
84
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);
122
88
void CSException::initException(const char *func, const char *file, int line, int err, const char *message)
124
90
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
142
108
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
143
109
iErrorCode = CS_ERR_ASSERTION;
144
cs_strcpy(CS_EXC_MESSAGE_SIZE, iMessage, "Assertion failed: ");
145
cs_strcat(CS_EXC_MESSAGE_SIZE, iMessage, message);
110
cs_strcpy(CS_EXC_MESSAGE_SIZE, iMessage, message);
148
113
void CSException::getCoreError(uint32_t size, char *buffer, int err)
181
146
cs_format_context(CS_EXC_CONTEXT_SIZE, iContext, func, file, line);
182
147
iErrorCode = err;
183
148
getCoreError(CS_EXC_MESSAGE_SIZE, iMessage, err);
184
cs_replace_string(CS_EXC_MESSAGE_SIZE, iMessage, "%s", item);
149
cs_replace_string(CS_EXC_MESSAGE_SIZE, iMessage, '%', item);
187
152
void CSException::initOSError(const char *func, const char *file, int line, int err)
292
e.initException(func, file, line, err, message);
257
e.initException(func, file, line, err,message);
293
258
e.log(NULL, "*** Uncaught error");
299
264
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");
323
267
void CSException::throwAssertion(const char *func, const char *file, int line, const char *message)
327
271
if ((self = CSThread::getSelf())) {
328
272
self->myException.initAssertion(func, file, line, message);
329
273
self->myException.setStackTrace(self);
330
/* Not sure why we log the excpetion down here?!
331
274
self->logException();
333
275
self->throwException();
470
412
void CSException::throwLastError(const char *func, const char *file, int line)
472
414
#ifdef OS_WINDOWS
473
throwOSError(func, file, line, (int) GetLastError());
415
throwOSError(func, file, line, (int) getLastError());
475
417
throwOSError(func, file, line, (int) errno);