Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
Error.h
Go to the documentation of this file.
1 
10 #ifndef __ERROR_H
11 #define __ERROR_H
12 
13 #include "../Core/SharedLibraryExportMacros.h"
14 #include <iostream>
15 #include <exception>
16 #include <string>
17 
18 namespace Core {
19 
21  namespace Error {
22 
27  class LIB_PUBLIC General : public std::exception {
28  private:
29  std::string message;
30  public:
32  General(const std::string &error_message="") :
33  message(error_message)
34  {
35  std::cerr << what() << ": " << error_message << std::endl;
36  }
37 
39  virtual const char *what() const throw() {return "general error";}
40 
42  const std::string &get_message() {return message;}
43 
45  virtual ~General() throw() {}
46  };
47 
49  class LIB_PUBLIC ALGLIB : public General {
50  public:
52  ALGLIB(const std::string &error_message="") :
53  General(error_message) {}
54 
56  virtual const char *what() const throw()
57  {return "ALGLIB error";}
58  };
59 
61  class LIB_PUBLIC Runtime : public General {
62  public:
64  Runtime(const std::string &error_message="") :
65  General(error_message) {}
66 
68  virtual const char *what() const throw()
69  {return "Run time error";}
70  };
71 
73  class LIB_PUBLIC BadFunctionArguments : public Runtime {
74  public:
76  BadFunctionArguments(const std::string &error_message="") :
77  Runtime(error_message) {
78  }
79 
81  virtual const char *what() const throw()
82  {return "Bad function arguments";}
83  };
84 
86  class LIB_PUBLIC BadStellarZone : public BadFunctionArguments {
87  public:
89  BadStellarZone(const std::string &error_message="") :
90  BadFunctionArguments(error_message) {}
91 
93  virtual const char *what() const throw()
94  {return "Invalid stellar zone";}
95  };
96 
98  class LIB_PUBLIC PathNotFound : public Runtime {
99  private:
101  bool directory;
102  public:
104  PathNotFound(const std::string &message,
105  const std::string &filename="",
106  bool isdir=false) :
107  Runtime(filename+", "+message), directory(isdir) {}
108 
110  virtual const char *what() const throw() {
111  return (directory ?
112  "Directory not found." :
113  "File not found.");
114  }
115  };
116 
118  class LIB_PUBLIC IO : public Runtime {
119  public:
121  IO(const std::string &filename="",
122  const std::string &error_message="") :
123  Runtime("Error reading "+filename+", "
124  +error_message) {}
126  virtual const char *what() const throw() {return "I/O error";}
127  };
128 
130  class LIB_PUBLIC CommandLine : public Runtime {
131  public:
133  CommandLine(const std::string &error_message="") :
134  Runtime(error_message) {}
135 
137  virtual const char *what() const throw()
138  {return "Error parsing the command line";}
139  };
140 
142  class LIB_PUBLIC NotImplemented : public Runtime {
143  public:
145  NotImplemented(const std::string &feature_name="") :
146  Runtime(feature_name+" not implemented yet") {}
147 
149  virtual const char *what() const throw()
150  {return "Not implemented";}
151  };
152 
154  class LIB_PUBLIC GSLZeroStep : public Runtime {
155  public:
157  GSLZeroStep(const std::string &gsl_step_type) :
158  Runtime("GSL "+gsl_step_type+" step size control requires zero "
159  "step size, aborting!") {}
160 
162  virtual const char *what() const throw()
163  {return "Tiny step";}
164  };
165 
167  class LIB_PUBLIC NonGSLZeroStep : public Runtime {
168  public:
171  Runtime("Breaking due to condtions or NaNs has decreased "
172  "maximum step size to zero! Aborting") {}
173 
175  virtual const char *what() const throw()
176  {return "Tiny step";}
177  };
178 
179  } //End Error namespace.
180 
181 } //End Core namespace.
182 
183 #endif
184 
virtual ~General()
Cleanup if necessary.
Definition: Error.h:45
virtual const char * what() const
Reports "Invalid stellar zone" as the error type.
Definition: Error.h:93
Maximum allowed step size decreased below machine precision.
Definition: Error.h:167
virtual const char * what() const
Returns "Tiny step" as the error type.
Definition: Error.h:162
Function arguments do not satisfy some requirement.
Definition: Error.h:73
IO(const std::string &filename="", const std::string &error_message="")
Create an Input/Ouput exception.
Definition: Error.h:121
virtual const char * what() const
Reports "Bad function arguments" as the erorr type.
Definition: Error.h:81
The base class of all exceptions.
Definition: Error.h:27
NotImplemented(const std::string &feature_name="")
Create a not-implemented exception.
Definition: Error.h:145
bool directory
Whether the problem was with a directory and not a file.
Definition: Error.h:101
PathNotFound(const std::string &message, const std::string &filename="", bool isdir=false)
Create a missing file or directory exception.
Definition: Error.h:104
virtual const char * what() const
Returns "Tiny step" as the error type.
Definition: Error.h:175
Runtime(const std::string &error_message="")
Create a runtime exception.
Definition: Error.h:64
Error detected by the ALGLIB library.
Definition: Error.h:49
Exception indicating unrecognized or unsuitable stellar zone.
Definition: Error.h:86
Any runtime error.
Definition: Error.h:61
Exception indicating that a file or a directory was not found.
Definition: Error.h:98
virtual const char * what() const
Returns "Not implemented" as the error type.
Definition: Error.h:149
virtual const char * what() const
Reports "ALGLIB error" as the error type.
Definition: Error.h:56
ALGLIB(const std::string &error_message="")
Create an exception for an error detected inside ALGLIB.
Definition: Error.h:52
Encountered an unimplemented feature.
Definition: Error.h:142
virtual const char * what() const
The type of error.
Definition: Error.h:39
CommandLine(const std::string &error_message="")
Create command line parsing exception.
Definition: Error.h:133
virtual const char * what() const
Reports "I/O error" as the error type.
Definition: Error.h:126
virtual const char * what() const
Reports "Run time error" as the eror type.
Definition: Error.h:68
Error related to parsing the command line.
Definition: Error.h:130
Input/Output exception.
Definition: Error.h:118
BadStellarZone(const std::string &error_message="")
Create a bad stellar zone exception.
Definition: Error.h:89
virtual const char * what() const
Returns "Error parsing the command line" as the error type.
Definition: Error.h:137
const std::string & get_message()
Details about what caused the error.
Definition: Error.h:42
NonGSLZeroStep()
Create a too-small GSL step size exception.
Definition: Error.h:170
General(const std::string &error_message="")
Create an exception.
Definition: Error.h:32
virtual const char * what() const
Reports "File/Directory not found" as the error type.
Definition: Error.h:110
GSL step size decreased below machine precision.
Definition: Error.h:154
GSLZeroStep(const std::string &gsl_step_type)
Create a too-small GSL step size exception.
Definition: Error.h:157
BadFunctionArguments(const std::string &error_message="")
Create bad function arguments exception.
Definition: Error.h:76