1//
2// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// Official repository: https://github.com/boostorg/beast
8//
9
10#ifndef BOOST_BEAST_TEST_IMPL_ERROR_IPP
11#define BOOST_BEAST_TEST_IMPL_ERROR_IPP
12
13#include <boost/beast/_experimental/test/error.hpp>
14
15namespace boost {
16namespace beast {
17namespace test {
18
19namespace detail {
20
21class error_codes : public error_category
22{
23public:
24 BOOST_BEAST_DECL
25 const char*
26 name() const noexcept override
27 {
28 return "boost.beast.test";
29 }
30
31 BOOST_BEAST_DECL
32 char const*
33 message(int ev, char*, std::size_t) const noexcept override
34 {
35 switch(static_cast<error>(ev))
36 {
37 default:
38 case error::test_failure: return
39 "An automatic unit test failure occurred";
40 }
41 }
42
43 BOOST_BEAST_DECL
44 std::string
45 message(int ev) const override
46 {
47 return message(ev, nullptr, 0);
48 }
49
50 BOOST_BEAST_DECL
51 error_condition
52 default_error_condition(int ev) const noexcept override
53 {
54 return error_condition{ev, *this};
55 }
56};
57
58} // detail
59
60error_code
61make_error_code(error e) noexcept
62{
63 static detail::error_codes const cat{};
64 return error_code{static_cast<
65 std::underlying_type<error>::type>(e), cat};
66}
67
68} // test
69} // beast
70} // boost
71
72#endif
73

source code of boost/libs/beast/include/boost/beast/_experimental/test/impl/error.ipp