libStatGen Software 1
Loading...
Searching...
No Matches
ErrorHandler.cpp
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ErrorHandler.h"
19#include "PhoneHome.h"
20
21#include <stdexcept>
22#include <stdlib.h>
23
24// Constructor
28
29
30// Destructor
34
35
36void ErrorHandler::handleError(const char* message,
37 HandlingType handlingType)
38{
39 // Check the handling type.
40 switch(handlingType)
41 {
42 case(EXCEPTION):
43 throw(std::runtime_error(message));
44 break;
45 case(ABORT):
46 std::cerr << message << "\nExiting" << std::endl;
47 PhoneHome::completionStatus("ErrorHandler: Exiting due to Error");
48 exit(-1);
49 break;
50 case(RETURN):
51 return;
52 break;
53 default:
54 std::cerr << message << "\nUnknown Handle Type: Exiting"
55 << std::endl;
56 PhoneHome::completionStatus("Exiting, ErrorHandler::unknown handle type.");
57 exit(-1);
58 break;
59 }
60}
61
static void handleError(const char *message, HandlingType handlingType=EXCEPTION)
Handle an error based on the error handling type.
~ErrorHandler()
Destructor.
ErrorHandler()
Constructor.
HandlingType
This specifies how this class should respond to errors.
@ RETURN
just return failure on the error
@ ABORT
exit the program on the error
@ EXCEPTION
throw an exception for the error