js8call/JS8_Main/MessageError.cpp

41 lines
1.2 KiB
C++
Raw Normal View History

2026-01-18 12:53:55 -06:00
/**
* @file MessageError.cpp
* @brief Implementation of the message error for external servers/clients
*/
#include "MessageError.h"
/******************************************************************************/
// Private Implementation
/******************************************************************************/
namespace {
const struct final : public std::error_category {
const char *name() const noexcept override { return "message"; }
std::string message(int const ev) const override {
using MessageError::Code;
switch (static_cast<Code>(ev)) {
case Code::json_parsing_error:
return "json parsing error";
case Code::json_not_an_object:
return "json not an object";
default:
return "message error";
}
}
} Category;
} // namespace
/******************************************************************************/
// Implementation
/******************************************************************************/
namespace MessageError {
std::error_category const &category() noexcept { return Category; }
} // namespace MessageError
/******************************************************************************/