Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

exceptions.hh

Go to the documentation of this file.
00001 /*
00002  @file   excpetions.hh exception handling for Doris InSAR processor
00003  @brief  exception handling for Doris InSAR processor
00004 */
00005 /*
00006  * Copyright (c) 1999-2005 Bert Kampes
00007  * Copyright (c) 1999-2005 Delft University of Technology, The Netherlands
00008  *
00009  * This file is part of Doris, the Delft o-o radar interferometric software.
00010  *
00011  * Doris program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * Doris is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  * Publications that contain results produced by the Doris software should
00026  * contain an acknowledgment. (For example: The interferometric processing
00027  * was performed using the freely available Doris software package developed
00028  * by the Delft Institute for Earth-Oriented Space Research (DEOS), Delft
00029  * University of Technology, or include a reference to: Bert Kampes and
00030  * Stefania Usai. \"Doris: The Delft Object-oriented Radar Interferometric
00031  * software.\" In: proceedings 2nd ITC ORS symposium, August 1999. (cdrom)).
00032  *
00033  */
00034 
00035 #ifndef EXCEPTIONS_H
00036 #define EXCEPTIONS_H
00037 
00038 using namespace std;                    // BK 29-Mar-2003, new compiler?
00039 
00040 #include <csignal>                      // function signal()
00041 
00042 
00043 
00044 /*********************************************************************
00045  * @brief exception handler for floating point exception
00046  *********************************************************************/
00047 void CatchSignals(void (*SigHandler)(int));
00048 void handle_signal(int signum);
00049 
00050 
00051 /*********************************************************************
00052  * @brief exception handler class
00053  *********************************************************************/
00054 // #include "exceptions.hh"  // this file..  
00055 // int main(
00056 //        int argc,
00057 //        char* argv[])
00058 // {
00059 // // ___ catch math errors ___
00060 // CatchSignals(handle_signal);
00061 //
00062 // try // --- start trying -----------------
00063 //   {
00064 //   code...
00065 //   if (error) throw(some_error);// object
00066 //   if (error) throw("sasas");// string
00067 //   }
00068 // }// --- end of try block; now catch thrown exceptions -------------
00069 // catch(EXCEPTION& error)// catch errors of EXCEPTION class
00070 //   {
00071 //   cerr << "i caught an error!" << endl;
00072 //   cerr << "i think: " << (const char*)error << endl;
00073 //   exit(1);
00074 //   }
00075 // catch(const char* error_string)// catch handled errors
00076 //   {
00077 //   cerr << "i caught an error_string!" << endl;
00078 //   cerr << "it is: " << error_string << endl;
00079 //   exit(2);
00080 //   }
00081 // catch(...) // catches other errors
00082 //   {
00083 //   cerr << "i caught an unhandled error!" << endl;
00084 //   exit(3);
00085 //   }
00086 //
00087 // cout << "\n\nNormal termination.\nThank you for using Doris.\n\n";
00088 // return int(0);
00089 // } // END main
00090 
00091 
00092 // ______ Base class for all error exceptions that can be caught ______
00093 class EXCEPTION
00094   {
00095   public:
00096     EXCEPTION()          {};
00097     virtual ~EXCEPTION() {};
00098     operator const char*() const {return(get_error_string());};
00099     virtual const char* get_error_string() const {return("generic error");};
00100   };
00101 // ______ Now all errors follow ______
00102 // ______ some error ______
00103 class SOME_ERROR : public EXCEPTION
00104   {
00105   private:
00106     char err_str[64];
00107   public:
00108     SOME_ERROR() {strcpy(err_str,"specific error");};
00109     virtual ~SOME_ERROR() {};
00110     operator const char*() const {return(get_error_string());};
00111     virtual const char* get_error_string() const {return(err_str);};
00112   };
00113 // ______ some input error ______
00114 class INPUT_ERROR : public EXCEPTION
00115   {
00116   private:
00117     char err_str[64];// make part of base class?
00118   public:
00119     INPUT_ERROR() {strcpy(err_str,"input error");};
00120     virtual ~INPUT_ERROR() {};
00121     operator const char*() const {return(get_error_string());};
00122     virtual const char* get_error_string() const {return(err_str);};
00123   };
00124 // ______ some file error ______
00125 class FILE_ERROR : public EXCEPTION
00126   {
00127   private:
00128     char err_str[64];// make part of base class?
00129   public:
00130     FILE_ERROR() {strcpy(err_str,"file error");};
00131     virtual ~FILE_ERROR() {};
00132     operator const char*() const {return(get_error_string());};
00133     virtual const char* get_error_string() const {return(err_str);};
00134   };
00135 // ______ memory error ______
00136 class MEMORY_ERROR : public EXCEPTION
00137   {
00138   private:
00139     char err_str[64];// make part of base class?
00140   public:
00141     MEMORY_ERROR() {strcpy(err_str,"memory error");};
00142     virtual ~MEMORY_ERROR() {};
00143     operator const char*() const {return(get_error_string());};
00144     virtual const char* get_error_string() const {return(err_str);};
00145   };
00146 // ______ unhandled case error ______
00147 class UNHANDLED_CASE_ERROR : public EXCEPTION
00148   {
00149   private:
00150     char err_str[64];// make part of base class?
00151   public:
00152     UNHANDLED_CASE_ERROR() {strcpy(err_str,"unhandled case error");};
00153     virtual ~UNHANDLED_CASE_ERROR() {};
00154     operator const char*() const {return(get_error_string());};
00155     virtual const char* get_error_string() const {return(err_str);};
00156   };
00157 // ______ unhandled case error ______
00158 class ARGUMENT_ERROR : public EXCEPTION
00159   {
00160   private:
00161     char err_str[64];// make part of base class?
00162   public:
00163     ARGUMENT_ERROR() {strcpy(err_str,"wrong input argument(s) to function");};
00164     virtual ~ARGUMENT_ERROR() {};
00165     operator const char*() const {return(get_error_string());};
00166     virtual const char* get_error_string() const {return(err_str);};
00167   };
00168 // ______ keyword error ______
00169 class KEYWORD_ERROR : public EXCEPTION
00170   {
00171   private:
00172     char err_str[64];// make part of base class?
00173   public:
00174     KEYWORD_ERROR() {strcpy(err_str,"incorrect keyword");};
00175     virtual ~KEYWORD_ERROR() {};
00176     operator const char*() const {return(get_error_string());};
00177     virtual const char* get_error_string() const {return(err_str);};
00178   };
00179 // ______ usage request error ______
00180 class USAGE_ERROR : public EXCEPTION
00181   {
00182   private:
00183     char err_str[64];// make part of base class?
00184   public:
00185     USAGE_ERROR() {strcpy(err_str,"done");};
00186     virtual ~USAGE_ERROR() {};
00187     operator const char*() const {return(get_error_string());};
00188     virtual const char* get_error_string() const {return(err_str);};
00189   };
00190 
00191 
00192 // ====== Globals to throw everywhere, e.g., throw(some_error) ======
00193 extern SOME_ERROR       some_error;// can be thrown from all programs
00194 extern INPUT_ERROR      input_error;// can be thrown from all programs
00195 extern FILE_ERROR       file_error;// can be thrown from all programs
00196 extern MEMORY_ERROR     memory_error;// can be thrown from all programs
00197 extern UNHANDLED_CASE_ERROR unhandled_case_error;// can be thrown from all programs
00198 extern ARGUMENT_ERROR   argument_error;// can be thrown from all programs
00199 extern KEYWORD_ERROR    keyword_error;// can be thrown from all programs
00200 extern USAGE_ERROR      usage_error;// can be thrown from all programs
00201 
00202 
00203 #endif // EXCEPTIONS_H
00204 
00205 

Generated on Fri Apr 22 15:57:52 2005 for Doris by doxygen 1.3.6