/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/db/include/RAT/DBExceptions.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/db/include/RAT/DBExceptions.hh Source File
Ratpac-two
DBExceptions.hh
1 #ifndef __RAT_DBExceptions__
2 #define __RAT_DBExceptions__
3 
4 #include <sstream>
5 #include <string>
6 
7 namespace RAT {
8 
10 class TextLoaderError {};
11 
13 class ParseError : public TextLoaderError {
14  public:
22  ParseError(int lnum, int cnum, std::string l, std::string mes) : linenum(lnum), colnum(cnum), line(l), message(mes){};
23 
29  std::string GetFull() const {
30  std::ostringstream s;
31  s << "Error on line " << linenum << ": " << message << std::endl;
32  s << line;
33  for (int i = 0; i < colnum; i++) s << " ";
34  s << "^" << std::endl;
35  return s.str();
36  };
37 
40  bool operator==(const ParseError &other) const {
41  return linenum == other.linenum && colnum == other.colnum && line == other.line && message == other.message;
42  };
43 
44  int linenum;
45  int colnum;
46  std::string line;
47  std::string message;
48 };
49 
51  public:
52  ProbablyJSONParseError(int lnum, int cnum, std::string l, std::string mes) : ParseError(lnum, cnum, l, mes){};
53 };
54 
56 class FileError : public TextLoaderError {
57  public:
58  FileError(std::string _filename) : filename(_filename){};
59  bool operator==(const FileError &other) const { return filename == other.filename; };
60 
61  std::string filename;
62 };
63 
65 class FileNotFoundError : public FileError {
66  public:
67  FileNotFoundError(std::string _filename) : FileError(_filename){};
68 };
69 
71 class FileAccessError : public FileError {
72  public:
73  FileAccessError(std::string _filename) : FileError(_filename){};
74 };
75 
76 } // namespace RAT
77 
78 #endif
Definition: DBExceptions.hh:71
Definition: DBExceptions.hh:56
Definition: DBExceptions.hh:65
Definition: DBExceptions.hh:13
int linenum
Definition: DBExceptions.hh:42
ParseError(int lnum, int cnum, std::string l, std::string mes)
Definition: DBExceptions.hh:22
bool operator==(const ParseError &other) const
Definition: DBExceptions.hh:40
std::string GetFull() const
Definition: DBExceptions.hh:29
int colnum
Definition: DBExceptions.hh:45
std::string line
Definition: DBExceptions.hh:46
std::string message
Definition: DBExceptions.hh:47
Definition: DBExceptions.hh:50
Definition: DBExceptions.hh:10
Definition: CCCrossSecMessenger.hh:29