| 29 | class Context; |
| 30 | |
| 31 | class Error |
| 32 | { |
| 33 | public: |
| 34 | class Reason |
| 35 | { |
| 36 | using self_type = Reason; |
| 37 | |
| 38 | public: |
| 39 | Reason() = default; |
| 40 | Reason(const self_type &) = delete; |
| 41 | void operator=(const self_type &) = delete; |
| 42 | |
| 43 | static void _set(cripts::Context *context, const cripts::string_view msg); |
| 44 | |
| 45 | private: |
| 46 | friend class Error; |
| 47 | |
| 48 | [[nodiscard]] cripts::string_view |
| 49 | _getter() const |
| 50 | { |
| 51 | return {_reason.c_str(), _reason.size()}; |
| 52 | } |
| 53 | |
| 54 | void |
| 55 | _setter(const cripts::string_view msg) |
| 56 | { |
| 57 | _reason = msg; |
| 58 | } |
| 59 | |
| 60 | cripts::string _reason; |
| 61 | }; |
| 62 | |
| 63 | #undef Status |
| 64 | #undef Error |
| 65 | class Status |
| 66 | { |
| 67 | using self_type = Status; |
| 68 | |
| 69 | public: |
| 70 | Status() = default; |
| 71 | Status(const self_type &) = delete; |
| 72 | void operator=(const self_type &) = delete; |
| 73 | |
| 74 | static void _set(cripts::Context *context, TSHttpStatus status, const cripts::string_view msg = {}); |
| 75 | |
| 76 | static void |
| 77 | _set(cripts::Context *context, int status, const cripts::string_view msg = {}) |
| 78 | { |
| 79 | _set(context, static_cast<TSHttpStatus>(status), msg); |
| 80 | } |
| 81 | |
| 82 | static TSHttpStatus _get(cripts::Context *context); |
| 83 | |
| 84 | private: |
| 85 | friend class Error; |
| 86 | |
| 87 | [[nodiscard]] TSHttpStatus |
| 88 | _getter() const |
no outgoing calls
no test coverage detected