2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------ */
25 /*=========================================================================
28 Module: $RCSfile: creaException.h,v $
30 Date: $Date: 2012/11/15 09:07:32 $
31 Version: $Revision: 1.3 $
34 This software is distributed WITHOUT ANY WARRANTY; without even
35 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
36 PURPOSE. See the above copyright notices for more information.
38 =========================================================================*/
43 * \brief class Exception:generic class for throwing any exception (header)
49 * \class crea::Exception
50 * \brief class Exception : generic class for throwing any exception
55 #ifndef __creaException_h__
56 #define __creaException_h__
58 #include "creaSystem.h"
59 #include "creaMessageManager.h"
64 inline std::string bbGetObjectDescription() { return(""); }
66 class CREA_EXPORT Exception : public std::exception
69 Exception(const std::string& object,
70 const std::string& source_file,
71 const std::string& message) throw()
73 mSourceFile(source_file),
76 mWhatMessage = " * ERROR : " + mMessage
77 + " * OBJECT : " + mObject
78 + " * FILE " + mSourceFile;
80 ~Exception() throw() {}
81 virtual const char* what() const throw()
83 return mWhatMessage.c_str();
88 std::cerr << "* ERROR : " << mMessage <<std::endl;
89 int lev = crea::MessageManager::GetMessageLevel("Error");
91 std::cerr << "* OBJECT : " <<mObject<<std::endl;
92 std::cerr << "* FILE : " <<mSourceFile<<std::endl;
95 const std::string& GetObject() const { return mObject; }
96 const std::string& GetSourceFile() const { return mSourceFile; }
97 const std::string& GetMessage() const { return mMessage; }
100 std::string mSourceFile;
101 std::string mMessage;
102 std::string mWhatMessage;