]> Creatis software - crea.git/commitdiff
overload what() -for unaware users-
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 4 Jun 2009 14:24:07 +0000 (14:24 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 4 Jun 2009 14:24:07 +0000 (14:24 +0000)
src/creaException.h
src/creaWx.h

index 81a2bd04c4303e603e48576924cc1c529d2a25be..faae382cf0a06b7bf20ece8eb4050ec69c3b1b70 100644 (file)
@@ -3,8 +3,8 @@
   Program:   crea
   Module:    $RCSfile: creaException.h,v $
   Language:  C++
-  Date:      $Date: 2008/09/26 14:09:55 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2009/06/04 14:24:07 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 #define __creaException_h__
 
 #include "creaSystem.h"
+#include "creaMessageManager.h"
 #include <exception>
 
 namespace crea
 {
-
   inline std::string bbGetObjectDescription() { return(""); }
 
   class CREA_EXPORT Exception : public std::exception
@@ -51,8 +51,17 @@ namespace crea
       : mObject(object),
        mSourceFile(source_file),
        mMessage(message)
-    {}
+    {
+       mWhatMessage = " * ERROR  : " + mMessage 
+                    + " * OBJECT : " + mObject
+                    + " * FILE "     + mSourceFile;
+    }
     ~Exception() throw() {}
+   virtual const char* what() const throw() 
+   {
+      return mWhatMessage.c_str();
+   }
+
     void Print() throw()
     {
       std::cerr << "* ERROR  : " << mMessage <<std::endl; 
@@ -62,13 +71,14 @@ namespace crea
        std::cerr << "* FILE   : " <<mSourceFile<<std::endl;
       }
     }
-    const std::string& GetObject() const { return mObject; }
+    const std::string& GetObject()     const { return mObject;     }
     const std::string& GetSourceFile() const { return mSourceFile; }
-    const std::string& GetMessage() const { return mMessage; }
+    const std::string& GetMessage()    const { return mMessage;    }
   private:
     std::string mObject;
     std::string mSourceFile;
     std::string mMessage;
+    std::string mWhatMessage;
   };
 
 }//namespace
index 7b63c86b6192140728790bc58e03872c5b8bf0c2..f442f7de8ce1a2dd6a2e6c368e9558a81b8b87d1 100644 (file)
@@ -46,6 +46,7 @@ typedef void wxWindow;
 //   In Visual C++ 6 (7 should be similar), to create an application that is both a console application 
 //  (cout's to the console are visible) and has a wxWidgets GUI, 
 //  you need to use the linker option "/subsystem:console" and the following code:
+
 #define CREA_WXMAIN_WITH_CONSOLE                                       \
   int main(int argc, char* argv[])                                     \
   {                                                                    \