]> Creatis software - clitk.git/blob - common/clitkExceptionObject.h
02f9579963e785322885c4a1ddbef54f7fd2d24c
[clitk.git] / common / clitkExceptionObject.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18
19 #ifndef CLITKEXCEPTIONOBJECT_H
20 #define CLITKEXCEPTIONOBJECT_H
21
22 // clitk
23 #include "clitkCommon.h"
24
25 // itk
26 #include "itkExceptionObject.h"
27
28 namespace clitk {
29
30   //--------------------------------------------------------------------
31   class ExceptionObject: public itk::ExceptionObject {
32   public:
33     ExceptionObject(const char *file, 
34                     unsigned int lineNumber=0,
35                     const char *desc="None");
36     virtual ~ExceptionObject() throw() {}
37     virtual const char* what() const throw();
38     std::string m_Message;
39     int m_LineNumber;
40     std::string m_Filename;
41   };
42   //--------------------------------------------------------------------
43   
44   //--------------------------------------------------------------------
45   // Largely inspired from itkExceptionMacro, but work without
46   // itkObject
47 #define clitkExceptionMacro(x)                                          \
48   {                                                                     \
49     ::itk::OStringStream message;                                       \
50     message << x;                                                       \
51     ::clitk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str()); \
52     throw e_; /* Explicit naming to work around Intel compiler bug.  */ \
53   }
54   //--------------------------------------------------------------------
55
56 } // end namespace clitk
57 //--------------------------------------------------------------------
58
59 #endif // CLITKEXCEPTIONOBJECT_H