Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/yacs.git] / src / bases / Exception.cxx
1 // Copyright (C) 2006-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "Exception.hxx"
21 #include <stdlib.h>
22
23 using namespace YACS;
24
25 //#define _DEVDEBUG_
26
27 #ifdef _DEVDEBUG_
28 #include <execinfo.h>
29 #endif
30
31 Exception::Exception(const std::string& what,int errNumber):_what(what),errNumber(errNumber)
32 {
33 #ifdef _DEVDEBUG_
34   void *array[20];
35   size_t size=10;
36   char **strings;
37   size_t i;
38
39   size = backtrace (array, 10);
40   strings = backtrace_symbols (array, size);
41
42   _what=_what+'\n';
43   for (i = 0; i < size; i++)
44      _what=_what+strings[i]+'\n';
45
46   free (strings);
47 #endif
48 }
49
50 const char *Exception::what( void ) const throw ()
51 {
52   return _what.c_str();
53 }
54
55 Exception::~Exception() throw ()
56 {
57 }