libStatGen Software  1
ErrorHandler.cpp
00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include "ErrorHandler.h"
00019 #include "PhoneHome.h"
00020 
00021 #include <stdexcept>
00022 #include <stdlib.h>
00023 
00024 // Constructor
00025 ErrorHandler::ErrorHandler()
00026 {
00027 }
00028 
00029    
00030 // Destructor
00031 ErrorHandler::~ErrorHandler()
00032 {
00033 }
00034 
00035 
00036 void ErrorHandler::handleError(const char* message, 
00037                                HandlingType handlingType)
00038 {
00039     // Check the handling type.
00040     switch(handlingType)
00041     {
00042         case(EXCEPTION):
00043             throw(std::runtime_error(message));
00044             break;
00045         case(ABORT):
00046             std::cerr << message << "\nExiting" << std::endl;
00047             PhoneHome::completionStatus("ErrorHandler: Exiting due to Error"); 
00048             exit(-1);
00049             break;
00050         case(RETURN):
00051             return;
00052             break;
00053         default:
00054             std::cerr << message << "\nUnknown Handle Type: Exiting" 
00055                       << std::endl;
00056             PhoneHome::completionStatus("Exiting, ErrorHandler::unknown handle type."); 
00057             exit(-1);
00058             break;
00059     }
00060 }
00061 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends