27 #ifndef DSC_EXCEPTION_HXX
28 #define DSC_EXCEPTION_HXX
30 #include "Utils_SALOME_Exception.hxx"
36 #include "utilities.h"
48 #if defined(_DEBUG_) || defined(_DEBUG)
50 # define LOC(message) (message), __FILE__ , __LINE__ , __FUNCTION__
52 # define LOC(message) (message), __FILE__, __LINE__
55 # define LOC(message) (message)
67 std::ostringstream oss_;
70 explicit OSS() : oss_() {}
73 OSS & operator<<(T obj)
79 operator std::string()
97 const char *makeText(
const char *text,
const char *fileName,
const unsigned int lineNumber);
109 const char *fileName=
"",
110 const unsigned int lineNumber=0,
111 const char *funcName=
"" ):
114 _filefuncName(setFileFuncName(fileName?fileName:
"",funcName?funcName:
"")),
115 _lineNumber(lineNumber),
116 _exceptionName(
"DSC_Exception")
119 delete [] ((
char*)SALOME_Exception::_text);
120 if (! _filefuncName.empty() )
121 SALOME_Exception::_text = makeText(text.c_str(),_filefuncName.c_str(),lineNumber) ;
123 SALOME_Exception::_text = makeText(text.c_str(),0,lineNumber) ;
126 oss << _exceptionName ;
127 if (!_filefuncName.empty() ) oss <<
" in " << _filefuncName;
128 if (_lineNumber) oss <<
" [" << _lineNumber <<
"]";
129 oss <<
" : " << _dscText;
133 virtual const char* what(
void )
const throw ()
135 return _what.c_str() ;
145 virtual const std::string & getExceptionName()
const {
return _exceptionName;};
149 std::string setFileFuncName(
const char * fileName,
const char * funcName) {
153 if ( strcmp(fileName,
"") )
154 oss << fileName <<
"##" << funcName;
161 std::string _dscText;
162 std::string _filefuncName;
164 std::string _exceptionName;
168 #define DSC_EXCEPTION(Derived) struct Derived : public DSC_Exception { \
169 Derived ( const std::string & text, const char *fileName="", const unsigned int lineNumber=0, const char *funcName="" \
170 ) : DSC_Exception(text,fileName,lineNumber,funcName) { \
171 _exceptionName = #Derived; \
173 virtual ~Derived(void) throw();\
179 #define DSC_EXCEPTION_CXX(NameSpace,Derived) NameSpace::Derived::~Derived(void) throw() {};