6 #ifndef WARNING_H_INCLUDED
7 #define WARNING_H_INCLUDED
49 using std::logic_error::logic_error;
75 template <
class E = rsvs_exception>
76 void error(
const char *message =
"",
const char *caller =
"",
const char *file =
"",
int line = 0,
77 bool throwError =
true);
87 template <
typename T>
int sign(T val);
88 int TimeStamp(
const char *str,
int start_s);
104 double Clock2ms(
int clockCycles);
113 #define RSVS3D_ERROR(M) (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
120 #define RSVS3D_ERROR_NOTHROW(M) (rsvs3d::error(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, false))
130 #define RSVS3D_ERROR_TYPE(M, T) (rsvs3d::error<T>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
139 #define RSVS3D_ERROR_LOGIC(M) (rsvs3d::error<std::logic_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
148 #define RSVS3D_ERROR_ARGUMENT(M) \
149 (rsvs3d::error<std::invalid_argument>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
151 #ifndef RSVS_NO_ARGCHECK
152 #define RSVS3D_ARGCHECK(E, M) \
155 RSVS3D_ERROR_ARGUMENT(M); \
157 #define RSVS3D_ARGCHECK_WARN(E, M) \
160 RSVS3D_ERROR_NOTHROW(M); \
163 #define RSVS3D_ARGCHECK(E, M)
164 #define RSVS3D_ARGCHECK_WARN(E, M)
173 #define RSVS3D_ERROR_RANGE(M) (rsvs3d::error<std::range_error>(M, __PRETTY_FUNCTION__, __FILE__, __LINE__, true))
175 void ThrowWarning(
const char *message);
187 template <
class T>
void CheckFStream(
const T &file,
const char *callerID,
const std::string &fileName)
192 errstr =
"Parameter file failed to open ";
195 errstr +=
" \n: " + fileName;
203 template <
class E>
void error(
const char *message,
const char *caller,
const char *file,
int line,
bool throwError)
205 std::cerr << std::endl <<
"Error at: " << file <<
":" << line << std::endl <<
" " << caller << std::endl;
212 std::cerr <<
"Exception (not thrown)" << message << std::endl;
215 template <
typename T>
int sign(T val)
217 return (T(0) < val) - (val < T(0));
Exception for signaling rsvs errors.
Namespace for general purpose tools of the RSVS project.
int sign(T val)
Returns the sign of a type comparable to 0.
double SignedLogScale(double in)
Returns a signed logscale useful for plotting data.
void error(const char *message="", const char *caller="", const char *file="", int line=0, bool throwError=true)
Custom error function.
void CheckFStream(const T &file, const char *callerID, const std::string &fileName)
Checks a file stream.
#define RSVS3D_ERROR_ARGUMENT(M)
Throw a invalid_argument.