Status class * * Class is an extension of std::exception and contains the underlying * status construct and an error explanatory message to be reported. * * @note Class is visible only when exceptions are enabled during compilation */
| 218 | * @note Class is visible only when exceptions are enabled during compilation |
| 219 | */ |
| 220 | class Status : public std::exception |
| 221 | { |
| 222 | public: |
| 223 | /** Constructor |
| 224 | * |
| 225 | * @param[in] status Status returned |
| 226 | * @param[in] msg Error message to be bound with the exception |
| 227 | */ |
| 228 | Status(StatusCode status, const std::string &msg) : _status(status), _msg(msg) |
| 229 | { |
| 230 | } |
| 231 | /** Returns an explanatory exception message |
| 232 | * |
| 233 | * @return Status message |
| 234 | */ |
| 235 | const char *what() const noexcept override |
| 236 | { |
| 237 | return _msg.c_str(); |
| 238 | } |
| 239 | /** Underlying status accessor |
| 240 | * |
| 241 | * @return Status code |
| 242 | */ |
| 243 | StatusCode status() const |
| 244 | { |
| 245 | return _status; |
| 246 | } |
| 247 | /** Explicit status converter |
| 248 | * |
| 249 | * @return Status code |
| 250 | */ |
| 251 | explicit operator StatusCode() const |
| 252 | { |
| 253 | return _status; |
| 254 | } |
| 255 | |
| 256 | private: |
| 257 | StatusCode _status; /**< Status code */ |
| 258 | std::string _msg; /**< Status message */ |
| 259 | }; |
| 260 | |
| 261 | /** Reports an error status and throws an exception object in case of failure |
| 262 | * |
no outgoing calls
no test coverage detected