libStatGen Software  1
Error.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 "Error.h"
19 
20 #include <stdlib.h>
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include "PhoneHome.h"
24 
25 // Declare a dummy class to ensure that compilers recognize this as C++ code
26 class String;
27 
28 void error(const char * msg, ...)
29 {
30  va_list ap;
31 
32  va_start(ap, msg);
33 
34  printf("\nFATAL ERROR - \n");
35  vprintf(msg, ap);
36  printf("\n\n");
37 
38  va_end(ap);
39 
40  PhoneHome::completionStatus("error: Exiting due to Fatal Error");
41  exit(EXIT_FAILURE);
42 }
43 
44 void warning(const char * msg, ...)
45 {
46  va_list ap;
47 
48  va_start(ap, msg);
49 
50  printf("\n\aWARNING - \n");
51  vprintf(msg, ap);
52  printf("\n");
53 
54  va_end(ap);
55 }
56 
57 void numerror(const char * msg , ...)
58 {
59  va_list ap;
60 
61  va_start(ap, msg);
62 
63  printf("\nFATAL NUMERIC ERROR - ");
64  vprintf(msg, ap);
65  printf("\n\n");
66 
67  va_end(ap);
68 
69  exit(EXIT_FAILURE);
70 }
String
Definition: StringBasics.h:39