Introduce MessageError namespace

This commit is contained in:
Allan Bazinet 2024-11-03 06:20:05 -08:00
parent 2f8a4f7c1e
commit c1fe8a431d
4 changed files with 105 additions and 8 deletions

51
MessageError.cpp Normal file
View file

@ -0,0 +1,51 @@
#include "MessageError.hpp"
/******************************************************************************/
// Private Implementation
/******************************************************************************/
#pragma mark 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;
}
/******************************************************************************/
// Private Implementation
/******************************************************************************/
#pragma mark - Implementation
namespace MessageError
{
std::error_category const &
category() noexcept
{
return Category;
}
}
/******************************************************************************/