]> Creatis software - clitk.git/blob - common/clitkExceptionObject.h
Change serie number to serie UID
[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://www.centreleonberard.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 #include <sstream>
23
24 // clitk
25 #include "clitkCommon.h"
26
27 // itk
28 #include "itkMacro.h"
29
30 namespace clitk {
31
32   //--------------------------------------------------------------------
33   class ExceptionObject: public itk::ExceptionObject {
34   public:
35     ExceptionObject(const char *file, 
36                     unsigned int lineNumber=0,
37                     const char *desc="None");
38     virtual ~ExceptionObject() throw() {}
39     virtual const char* what() const throw();
40     std::string m_Message;
41     int m_LineNumber;
42     std::string m_Filename;
43   };
44   //--------------------------------------------------------------------
45   
46   //--------------------------------------------------------------------
47   // Largely inspired from itkExceptionMacro, but work without
48   // itkObject
49 #define clitkExceptionMacro(x)                                          \
50   {                                                                     \
51     std::ostringstream message;                                       \
52     message << x;                                                       \
53     ::clitk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str()); \
54     throw e_; /* Explicit naming to work around Intel compiler bug.  */ \
55   }
56   //--------------------------------------------------------------------
57
58 } // end namespace clitk
59 //--------------------------------------------------------------------
60
61 #endif // CLITKEXCEPTIONOBJECT_H