Feat C++ API
A feature engineering automation tool
error.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 
6 #include "error.h"
7 #include <stdexcept>
8 
9 //#include "node/node.h"
10 //external includes
11 
12 namespace FT{
13 
14 namespace Util{
16 void ThrowRuntimeError(string err, const char *file, int line)
17 {
18  string str_file(file);
19  err = "ERROR: " + str_file + ", line " + std::to_string(line) + ": " + err;
20  throw std::runtime_error(err);
21 }
22 void ThrowInvalidArgument(string err, const char *file, int line)
23 {
24  string str_file(file);
25  err = "ERROR: " + str_file + ", line " + std::to_string(line) + ": " + err;
26  throw std::invalid_argument(err);
27 }
28 void ThrowLengthError(string err, const char *file, int line)
29 {
30  string str_file(file);
31  err = "ERROR: " + str_file + ", line " + std::to_string(line) + ": " + err;
32  throw std::length_error(err);
33 }
35 void Warn(string err, const char *file, int line )
36 {
37  string str_file(file);
38  err = "WARNING: " + str_file + ", line " + std::to_string(line) + ": " + err;
39  std::cout << err << "\n";
40 }
41 
43 void my_handler(int s)
44 {
45  WARN("Caught signal "+ to_string(s) +", exiting");
46  exit(1);
47 }
48 
49 }
50 }
51 
#define WARN(err)
Definition: error.h:33
void my_handler(int s)
handle signals (ctr-c etc.)
Definition: error.cc:43
void ThrowInvalidArgument(string err, const char *file, int line)
Definition: error.cc:22
void ThrowRuntimeError(string err, const char *file, int line)
prints error and throws an exception
Definition: error.cc:16
void ThrowLengthError(string err, const char *file, int line)
Definition: error.cc:28
void Warn(string err, const char *file, int line)
prints error to stderr and returns
Definition: error.cc:35
std::string to_string(const T &value)
template function to convert objects to string for logging
Definition: utils.h:422
main Feat namespace
Definition: data.cc:13