libStatGen Software
1
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
25
ErrorHandler::ErrorHandler
()
26
{
27
}
28
29
30
// Destructor
31
ErrorHandler::~ErrorHandler
()
32
{
33
}
34
35
36
void
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
ErrorHandler::handleError
static void handleError(const char *message, HandlingType handlingType=EXCEPTION)
Handle an error based on the error handling type.
Definition:
ErrorHandler.cpp:36
ErrorHandler::~ErrorHandler
~ErrorHandler()
Destructor.
Definition:
ErrorHandler.cpp:31
ErrorHandler::RETURN
@ RETURN
just return failure on the error
Definition:
ErrorHandler.h:31
ErrorHandler::HandlingType
HandlingType
This specifies how this class should respond to errors.
Definition:
ErrorHandler.h:29
ErrorHandler::EXCEPTION
@ EXCEPTION
throw an exception for the error
Definition:
ErrorHandler.h:29
ErrorHandler::ABORT
@ ABORT
exit the program on the error
Definition:
ErrorHandler.h:30
ErrorHandler::ErrorHandler
ErrorHandler()
Constructor.
Definition:
ErrorHandler.cpp:25
general
ErrorHandler.cpp
Generated by
1.8.18