1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/* Copyright (C) 2006 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
// Error.cpp: implementation of the Error class.
//
//////////////////////////////////////////////////////////////////////
// copyright (c) 1999 - 2000 by James A. Starkey
#ifdef _WIN32
#include <windows.h>
#endif
#include <stdarg.h>
#include <stdio.h>
#include <signal.h>
#include "Engine.h"
#include "Error.h"
#include "SQLError.h"
#include "Log.h"
//#include "MemMgr.h"
//#define CHECK_HEAP
#ifdef CHECK_HEAP
#include <crtdbg.h>
#endif
#ifdef _DEBUG
#undef THIS_FILE
static const char THIS_FILE[]=__FILE__;
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
void Error::error(const char * string, ...)
{
char buffer [256];
va_list args;
va_start (args, string);
if (vsnprintf (buffer, sizeof (buffer) - 1, string, args) < 0)
buffer [sizeof (buffer) - 1] = 0;
#ifdef FALCONDB
// Always write unrecoverable error info to the error log
fprintf (stderr, "[Falcon] Error: %s\n", buffer);
Log::logBreak ("Bugcheck: %s\n", buffer);
//MemMgrLogDump();
#endif
debugBreak();
throw SQLEXCEPTION (BUG_CHECK, buffer);
}
void Error::assertionFailed(const char *text, const char * fileName, int line)
{
error ("assertion (%s) failed at line %d in file %s\n", text, line, fileName);
}
void Error::validateHeap(const char *where)
{
#ifdef CHECK_HEAP
if (!_CrtCheckMemory())
Log::debug ("***> memory corrupted at %s!!!\n", where);
#endif
}
void Error::debugBreak()
{
#ifdef _WIN32
DebugBreak();
#else
raise (SIGABRT);
#endif
}
void Error::notYetImplemented(const char *fileName, int line)
{
#ifdef FALCONDB
Log::logBreak ("feature not yet implemented at line %d in file %s\n", line, fileName);
#endif
throw SQLEXCEPTION (FEATURE_NOT_YET_IMPLEMENTED, "feature not yet implemented at line %d in file %s\n", line, fileName);
}
|