File: MessageError.cpp

package info (click to toggle)
js8call 2.5.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,720 kB
  • sloc: cpp: 562,655; sh: 898; python: 132; ansic: 102; makefile: 4
file content (35 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#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

/******************************************************************************/