AFLOW
 
Loading...
Searching...
No Matches
aurostd_xerror.h
Go to the documentation of this file.
1//****************************************************************************
2// * *
3// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
4// * Aflow MARCO ESTERS - Duke University 2018-2021 *
5// * *
6//****************************************************************************
7#ifndef _AUROSTD_XERROR_H_
8#define _AUROSTD_XERROR_H_
9
10#include <sstream>
11#include <string>
12
13// BEGIN CONSTANTS
14// Definitions for the named error code constant (see README, section 2.1.).
15#define _GENERIC_ERROR_ 1
16#define _ILLEGAL_CODE_ 2
17#define _INPUT_ERROR_ 10
18#define _INPUT_UNKNOWN_ 11
19#define _INPUT_MISSING_ 12
20#define _INPUT_AMBIGUOUS_ 13
21#define _INPUT_ILLEGAL_ 14
22#define _INPUT_NUMBER_ 15
23#define _FILE_ERROR_ 20
24#define _FILE_NOT_FOUND_ 21
25#define _FILE_WRONG_FORMAT_ 22
26#define _FILE_CORRUPT_ 23
27#define _VALUE_ERROR_ 30
28#define _VALUE_ILLEGAL_ 31
29#define _VALUE_RANGE_ 32
30#define _INDEX_ERROR_ 40
31#define _INDEX_ILLEGAL_ 41
32#define _INDEX_BOUNDS_ 42
33#define _INDEX_MISMATCH_ 43
34#define _RUNTIME_ERROR_ 50
35#define _RUNTIME_INIT_ 51
36#define _RUNTIME_SQL_ 52
37#define _RUNTIME_BUSY_ 53
38#define _RUNTIME_EXTERNAL_MISS_ 54 // CO20200531
39#define _RUNTIME_EXTERNAL_FAIL_ 55 // CO20200531
40#define _RUNTIME_HTTP_ 56 // ME20220426
41#define _ALLOC_ERROR_ 60
42#define _ALLOC_ALLOCATE_ 61
43#define _ALLOC_INSUFFICIENT_ 62
44
45namespace aurostd {
46
47 extern std::string xerror_PID; // SC20200508
48 // END CONSTANTS
49
50 class xerror {
51 public:
52 xerror(const std::string&, const std::string&, const std::string&, int = 1);
53 xerror(const std::string&, const std::string&, const std::stringstream&, int = 1);
54 xerror(const std::string&, const std::stringstream&, const std::stringstream&, int = 1);
55 xerror(const std::string&, const std::stringstream&, const std::string&, int = 1);
56 ~xerror() throw() {};
57 std::string what();
58 [[nodiscard]] int whatCode() const;
59 std::string whereFunction(); // CO20191201
60 std::string whereFileName(); // CO20191201
61 std::string buildMessageString();
62
63 private:
67 std::string file_name;
68 std::string function_name;
69 std::string error_message;
70
71 void buildException(const std::string&, const std::string&, const std::string&, const int&);
72 [[nodiscard]] bool codeValid() const;
73 [[nodiscard]] std::string error_string() const;
74 };
75} // namespace aurostd
76
77#endif
78//****************************************************************************
79// * *
80// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
81// * Aflow MARCO ESTERS - Duke University 2018-2021 *
82// * *
83//****************************************************************************
std::string what()
std::string error_string() const
std::string file_name
std::string buildMessageString()
std::string function_name
bool codeValid() const
std::string whereFileName()
void buildException(const std::string &, const std::string &, const std::string &, const int &)
std::string whereFunction()
xerror(const std::string &, const std::string &, const std::string &, int=1)
std::string error_message
string xerror_PID