ae2f_docs
errGlob.hpp
Go to the documentation of this file.
1/**
2 * @file errGlob.hpp
3 * @author ae2f
4 * @brief
5 * @date 2025-02-01
6 *
7 * @copyright Copyright (c) 2025
8 *
9 */
10#ifndef ae2f_errGlob_hpp
11#define ae2f_errGlob_hpp
12
13
14#include "BitVec.hpp"
15#include "errGlob.h"
16#include <exception>
17#include <string>
18
19#include "Pack/Beg.h"
20
21namespace ae2f {
22
23/// @brief
24/// Gets the code
28
29 /// @brief
30 /// It is a constructor, which will throw it is a state critical.
31 /// @param a
32 /// Raw status code
33 /// @return
34 /// error parser for a.
35 /// @see ae2f_errGlobNormalised
37
38 /// @brief
39 /// Gets one
40 /// @return
41 /// A single error message for this code.
42 constexprmethod const char *peek() const noexcept {
44 ? "Failed to find the function on preprocessor which is "
45 "callable "
46 "for some reason No operation has beed done."
48 ? "Failed to refer the pointer either l-value inside the "
49 "function."
50 : (code & ae2f_errGlob_FLUSH_FAILED) ? "Failed freeing the memory."
52 ? "stdlib allocating functions (malloc, calloc, realloc) has "
53 "been "
54 "failed."
56 ? "Found that parameter sent by programmer is invalid. The "
57 "operation may have been ceased while the middle."
59 ? "Found some errors, but not by parameters. The operation has "
60 "failed."
62 ? "The operation went done. Note that operation may not be "
63 "valid."
64 : (code) ? "Unexpected flag."
65 : "The operation went done.";
66 }
67
68 /// @brief
69 /// Pops an error with an error type.
70 /// @return
71 /// Error message
75
76 /// @brief
77 /// Generates the error message.
78 /// @return
79 /// A whole list of error messages.
80 inline std::string msgall() const noexcept;
81};
82
84inline std::string errGlobState::msgall() const noexcept {
85 std::string rtn = "Following shows the error flag enabled.";
87
88 while (err.code) {
89 rtn += '\t';
90 rtn += err.peek();
91 err = err.pop();
92 rtn += '\n';
93 }
94
95 return rtn;
96}
97
98/// @brief
99/// Thrown error type.
100class errGlobThrown : public std::exception {
101 friend class errGlobState;
102
103 errGlobState code;
104 /// @brief
105 /// Error message buffer;
106 const std::string msg;
107
108 inline errGlobThrown(const ae2f_err_t c) noexcept
109 : code(c), msg(code.msgall()) {}
110
111 inline virtual const char *what() const noexcept override {
112 return msg.c_str();
113 }
114};
115
118 throw errGlobThrown(a);
119 return a;
120}
121
122} // namespace ae2f
123#include "Pack/End.h"
124
125#endif
#define constexprmethod
Definition Constexpr.hpp:50
#define constextendedmethod
Definition Constexpr.hpp:43
Thrown error type.
Definition errGlob.hpp:100
constextendedmethod const rBitVec< t > FndOne() const noexcept
Definition BitVec.hpp:92
constexprmethod rBitVec(const t &obj) noexcept
Definition BitVec.hpp:41
#define ae2f_errGlob_ALLOC_FAILED
stdlib allocating functions (malloc, calloc, realloc) has been failed.
Definition errGlob.h:40
#define ae2f_errGlob_NFOUND
Found some errors, but not by parameters. The operation has failed.
Definition errGlob.h:50
#define ae2f_errGlob_DONE_HOWEV
Means that error was not critical.
Definition errGlob.h:57
#define ae2f_errGlob_WRONG_OPERATION
Found that parameter sent by programmer is invalid. The operation may have been ceased while the midd...
Definition errGlob.h:45
uint8_t ae2f_err_t
Informs that this number represents the error.
Definition errGlob.h:19
#define ae2f_errGlob_PTR_IS_NULL
Failed to refer the pointer either l-value inside the function.
Definition errGlob.h:32
#define ae2f_errGlob_FLUSH_FAILED
Failed freeing the memory.
Definition errGlob.h:36
#define ae2f_errGlobNormalised(n)
Check if the state code is a critical error.
Definition errGlob.h:63
#define ae2f_errGlob_IMP_NOT_FOUND
Failed to find the function on preprocessor which is callable for some reason No operation has beed d...
Definition errGlob.h:28
This namespace contains the class from this library.
Definition BitVec.hpp:23
Gets the code.
Definition errGlob.hpp:25
static errGlobState errGlobStateWithThrow(ae2f_err_t a)
It is a constructor, which will throw it is a state critical.
Definition errGlob.hpp:116
constexprmethod const char * peek() const noexcept
Gets one.
Definition errGlob.hpp:42
constextendedmethod errGlobState pop() const noexcept
Pops an error with an error type.
Definition errGlob.hpp:72
ae2f_err_t code
Definition errGlob.hpp:26
std::string msgall() const noexcept
Generates the error message.
Definition errGlob.hpp:84
constexprmethod errGlobState(ae2f_err_t a) noexcept
Definition errGlob.hpp:83