4
// Copyright (c) 1998-2002 by The VoxBo Development Team
6
// This file is part of VoxBo
8
// VoxBo is free software: you can redistribute it and/or modify it
9
// under the terms of the GNU General Public License as published by
10
// the Free Software Foundation, either version 3 of the License, or
11
// (at your option) any later version.
13
// VoxBo is distributed in the hope that it will be useful, but
14
// WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// General Public License for more details.
18
// You should have received a copy of the GNU General Public License
19
// along with VoxBo. If not, see <http://www.gnu.org/licenses/>.
21
// For general information on VoxBo, including the latest complete
22
// source code and binary distributions, manual, and associated files,
23
// see the VoxBo home page at: http://www.voxbo.org/
25
// original version written by Kosh Banerjee
29
#include "genericexcep.h"
32
/********************************************************************
33
* The GenericExcep class: *
34
********************************************************************/
36
/********************************************************************
37
* Initializing the static data members. *
38
********************************************************************/
39
string GenericExcep::error = "[E] ";
40
string GenericExcep::file = " In File: [";
41
string GenericExcep::lineNumb = "] Line Number: [";
42
string GenericExcep::func = "] In function: [";
44
/********************************************************************
45
* Constructors for GenericExcep: *
46
********************************************************************/
47
GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const char *mesg)
49
this->init(line, fileNm, func);
50
this->message = string(mesg);
52
} // GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const char *mesg)
54
GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const string mesg)
56
this->init(line, fileNm, func);
59
} // GenericExcep::GenericExcep(const int line, const char *fileNm, const char *func, const string mesg)
61
void GenericExcep::init(const int line, const char *fileNm, const char *func)
64
this->fileName = fileNm;
65
this->funcName = func;
68
} // GenericExcep::init(const int line, const char *fileNm, const char *func)
70
void GenericExcep::what(int line, string file, string function)
72
this->whatNoExit(line, file, function);
75
} // virtual void GenericExcep::what(int, string, string) const
77
void GenericExcep::whatAbort(int line, string file, string function)
79
this->whatNoExit(line, file, function);
81
} // virtual void GenericExcep::whatAbort(int line, string file, string function)
83
void GenericExcep::whatNoExit(int line, string file, string function)
85
return; // FIXME DYK: this quick and dirty fix eliminates all those
86
// spurious console messages from vb_vector
87
char intString[INT_STRING_SIZE];
88
(void) memset (intString, 0, sizeof(intString));
89
(void) sprintf (intString, "%d", this->lineNo);
91
errMsg = this->error + this->message + this->file + this->fileName
92
+ this->lineNumb + intString + this->func + this->funcName + "]";
94
(void) memset (intString, 0, sizeof(intString));
95
(void) sprintf (intString, "%d", line);
96
caller = "[X] FROM: Line Number [" + (string) intString
97
+ "] Function [" + function + "] File [" + file + "]";
99
cerr << caller << endl;
100
cerr << errMsg << endl;
102
} // virtual void GenericExcep::whatNoExit(int, string, string) const
104
void GenericExcep::what()
106
this->what(0, "UNKNOWN", "UNKNOWN");
107
} // virtual void GenericExcep::what() const