1 
2 #ifdef HAVE_CONFIG_H
3 #include "OPT++_config.h"
4 #endif
5 
6 #include <iostream>
7 #ifdef HAVE_STD
8 #include <cstdlib>
9 #else
10 #include <stdlib.h>
11 #endif
12 
13 #include "OptppFatalError.h"
14 
15 using namespace std;
16 
17 namespace OPTPP{
18 
19 // user-level error-invocation functions. These will throw an exception
20 // if exceptions are supported, otherwise they will print a mesg and
21 // exit.
22 
OptppfatalError(const char * mesg)23 void OptppfatalError(const char* mesg)
24 {
25 #ifdef USEEXCEPTIONS
26 	throw OptppExceptions(mesg);
27 #else
28 	cerr << "fatal error: " << mesg << endl;
29 	exit(1);
30 #endif
31 }
32 
OptppmemoryError(const char * mesg)33 void OptppmemoryError(const char* mesg)
34 {
35 #ifdef USEEXCEPTIONS
36 	throw OptppMemoryError(mesg);
37 #else
38 	cerr << "memory error: " << mesg << endl;
39 	exit(1);
40 #endif
41 }
42 
OptpprangeError(const char * mesg,int i,int low,int high)43 void OptpprangeError(const char* mesg, int i, int low, int high)
44 {
45 #ifdef USEEXCEPTIONS
46 	throw OptppRangeError(mesg, i, low, high);
47 #else
48 	cerr << "range error: " << mesg << " index=" << i << " bounds:["
49 			 << low << ", " << high << "]" << endl;
50 	exit(1);
51 #endif
52 }
53 
OptppmathError(const char * mesg)54 void OptppmathError(const char* mesg)
55 {
56 #ifdef USEEXCEPTIONS
57 	throw OptppMathError(mesg);
58 #else
59 	cerr << "math error: " << mesg << endl;
60 	exit(1);
61 #endif
62 }
63 
OptppdomainError(const char * mesg,const double & badValue)64 void OptppdomainError(const char* mesg, const double& badValue)
65 {
66 #ifdef USEEXCEPTIONS
67 	throw OptppDomainError(mesg, badValue);
68 #else
69 	cerr << "domain error: " << mesg << " bad value = " << badValue << endl;
70 	exit(1);
71 #endif
72 }
73 
OptppzeroDivide(const char * mesg)74 void OptppzeroDivide(const char* mesg)
75 {
76 #ifdef USEEXCEPTIONS
77 	throw OptppZeroDivide(mesg);
78 #else
79 	cerr << "division by zero error: " << mesg << endl;
80 	exit(1);
81 #endif
82 }
83 
84 } // namespace OPTPP
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96