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

exceptions.cc

Go to the documentation of this file.
00001 /*
00002  @file   excpetions.cc 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 #include <csignal>                      // function signal()
00036 #include <iostream>                     // cerr
00037 #include "exceptions.hh"                // class
00038 
00039 
00040 
00041 // ====== Globals to throw everywhere, e.g., throw(some_error) ======
00042 SOME_ERROR           some_error;// can be thrown from all programs
00043 INPUT_ERROR          input_error;// can be thrown from all programs
00044 FILE_ERROR           file_error;// can be thrown from all programs
00045 MEMORY_ERROR         memory_error;// can be thrown from all programs
00046 UNHANDLED_CASE_ERROR unhandled_case_error;// can be thrown from all programs
00047 ARGUMENT_ERROR       argument_error;// can be thrown from all programs
00048 KEYWORD_ERROR        keyword_error;// can be thrown from all programs
00049 USAGE_ERROR          usage_error;// can be thrown from all programs
00050 
00051 
00052 
00053 
00054 /*********************************************************************
00055  * @brief exception handler for floating point exception
00056  *********************************************************************/
00057 /* function: CatchSignals()
00058  * ------------------------
00059  * Traps common signals that by default cause the program to abort.  
00060  * Sets (pointer to function) Handler as the signal handler for all.
00061  * Note that SIGKILL usually cannot be caught.  No return value.
00062  */   // following is from snaphu:
00063 void CatchSignals(void (*SigHandler)(int)){
00064   signal(SIGHUP,SigHandler);
00065   signal(SIGINT,SigHandler);
00066   signal(SIGQUIT,SigHandler);
00067   signal(SIGILL,SigHandler);
00068   signal(SIGABRT,SigHandler);
00069   signal(SIGFPE,SigHandler);
00070   signal(SIGSEGV,SigHandler);
00071   signal(SIGPIPE,SigHandler);
00072   signal(SIGALRM,SigHandler);
00073   signal(SIGTERM,SigHandler);
00074   signal(SIGBUS,SigHandler);
00075 }
00076 
00077 
00078 
00079 /* function: SetDump()
00080  * -------------------
00081  * Set the global variable dumpresults_global to TRUE if SIGINT or SIGHUP
00082  * signals recieved.  Also sets requestedstop_global if SIGINT signal 
00083  * received.  This function should only be called via signal() when 
00084  * a signal is caught.
00085  */    // following is from snaphu:
00086 void handle_signal(int signum)
00087   {
00088   switch (signum)
00089     {
00090     case SIGFPE:
00091       cout << "Caught SIGFPE: floating point exception, zero division, etc." << endl;
00092       cerr << "Caught SIGFPE: floating point exception, zero division, etc." << endl;
00093       break;
00094     case SIGHUP:
00095       cout << "Caught SIGHUP: Hang-up signal." << endl;
00096       cerr << "Caught SIGHUP: Hang-up signal." << endl;
00097       break;
00098     case SIGINT:
00099       cout << "Caught SIGINT: User interupt signal." << endl;
00100       cerr << "Caught SIGINT: User interupt signal." << endl;
00101       break;
00102     case SIGQUIT:
00103       cout << "Caught SIGQUIT: Quit signal." << endl;
00104       cerr << "Caught SIGQUIT: Quit signal." << endl;
00105       break;
00106     case SIGILL:
00107       cout << "Caught SIGILL: ? signal." << endl;
00108       cerr << "Caught SIGILL: ? signal." << endl;
00109       break;
00110     case SIGABRT:
00111       cout << "Caught SIGABRT: Abort signal." << endl;
00112       cerr << "Caught SIGABRT: Abort signal." << endl;
00113       break;
00114     case SIGSEGV:
00115       cout << "Caught SIGSEGV: ? signal." << endl;
00116       cerr << "Caught SIGSEGV: ? signal." << endl;
00117       break;
00118     case SIGPIPE:
00119       cout << "Caught SIGPIPE: ? signal." << endl;
00120       cerr << "Caught SIGPIPE: ? signal." << endl;
00121       break;
00122     case SIGALRM:
00123       cout << "Caught SIGALRM: Alarm signal." << endl;
00124       cerr << "Caught SIGALRM: Alarm signal." << endl;
00125       break;
00126     case SIGTERM:
00127       cout << "Caught SIGTERM: ? signal." << endl;
00128       cerr << "Caught SIGTERM: ? signal." << endl;
00129       break;
00130     case SIGBUS:
00131       cout << "Caught SIGBUS: Bus error signal?" << endl;
00132       cerr << "Caught SIGBUS: Bus error signal?" << endl;
00133       break;
00134     default:
00135       cout << "Caught an unknown signal?" << endl;
00136       cerr << "Caught an unknown signal?" << endl;
00137     }
00138   }
00139 
00140 
00141 
00142 

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