libs/http/src/detail/except.cpp
63.6% Lines (21/33)
63.6% Functions (7/11)
66.7% Branches (6/9)
libs/http/src/detail/except.cpp
| Line | Branch | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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/cppalliance/http | ||
| 8 | // | ||
| 9 | |||
| 10 | #include <boost/http/detail/except.hpp> | ||
| 11 | #include <boost/system/system_error.hpp> | ||
| 12 | #include <boost/version.hpp> | ||
| 13 | #include <boost/throw_exception.hpp> | ||
| 14 | #include <stdexcept> | ||
| 15 | #include <typeinfo> | ||
| 16 | |||
| 17 | namespace boost { | ||
| 18 | namespace http { | ||
| 19 | namespace detail { | ||
| 20 | |||
| 21 | void | ||
| 22 | ✗ | throw_bad_alloc( | |
| 23 | source_location const& loc) | ||
| 24 | { | ||
| 25 | ✗ | throw_exception( | |
| 26 | ✗ | std::bad_alloc(), loc); | |
| 27 | } | ||
| 28 | |||
| 29 | void | ||
| 30 | 1 | throw_bad_typeid( | |
| 31 | source_location const& loc) | ||
| 32 | { | ||
| 33 | 1 | throw_exception( | |
| 34 | 2 | std::bad_typeid(), loc); | |
| 35 | } | ||
| 36 | |||
| 37 | void | ||
| 38 | 27 | throw_invalid_argument( | |
| 39 | source_location const& loc) | ||
| 40 | { | ||
| 41 | 27 | throw_exception( | |
| 42 |
1/1✓ Branch 1 taken 27 times.
|
54 | std::invalid_argument( |
| 43 | "invalid argument"), | ||
| 44 | loc); | ||
| 45 | } | ||
| 46 | |||
| 47 | void | ||
| 48 | 4 | throw_invalid_argument( | |
| 49 | char const* what, | ||
| 50 | source_location const& loc) | ||
| 51 | { | ||
| 52 | 4 | throw_exception( | |
| 53 |
1/1✓ Branch 1 taken 4 times.
|
8 | std::invalid_argument(what), loc); |
| 54 | } | ||
| 55 | |||
| 56 | void | ||
| 57 | 23 | throw_length_error( | |
| 58 | source_location const& loc) | ||
| 59 | { | ||
| 60 | 23 | throw_exception( | |
| 61 |
1/1✓ Branch 1 taken 23 times.
|
46 | std::length_error( |
| 62 | "length error"), loc); | ||
| 63 | } | ||
| 64 | |||
| 65 | void | ||
| 66 | 1 | throw_length_error( | |
| 67 | char const* what, | ||
| 68 | source_location const& loc) | ||
| 69 | { | ||
| 70 | 1 | throw_exception( | |
| 71 |
1/1✓ Branch 1 taken 1 time.
|
2 | std::length_error(what), loc); |
| 72 | } | ||
| 73 | |||
| 74 | void | ||
| 75 | 21 | throw_logic_error( | |
| 76 | source_location const& loc) | ||
| 77 | { | ||
| 78 | 21 | throw_exception( | |
| 79 |
1/1✓ Branch 1 taken 21 times.
|
42 | std::logic_error( |
| 80 | "logic error"), | ||
| 81 | loc); | ||
| 82 | } | ||
| 83 | |||
| 84 | void | ||
| 85 | ✗ | throw_out_of_range( | |
| 86 | source_location const& loc) | ||
| 87 | { | ||
| 88 | ✗ | throw_exception( | |
| 89 | ✗ | std::out_of_range("out of range"), loc); | |
| 90 | } | ||
| 91 | |||
| 92 | void | ||
| 93 | ✗ | throw_runtime_error( | |
| 94 | char const* what, | ||
| 95 | source_location const& loc) | ||
| 96 | { | ||
| 97 | ✗ | throw_exception( | |
| 98 | ✗ | std::runtime_error(what), loc); | |
| 99 | } | ||
| 100 | |||
| 101 | void | ||
| 102 | 21 | throw_system_error( | |
| 103 | system::error_code const& ec, | ||
| 104 | source_location const& loc) | ||
| 105 | { | ||
| 106 | 21 | throw_exception( | |
| 107 |
1/1✓ Branch 1 taken 21 times.
|
42 | system::system_error(ec), loc); |
| 108 | } | ||
| 109 | |||
| 110 | void | ||
| 111 | ✗ | throw_system_error( | |
| 112 | error e, | ||
| 113 | source_location const& loc) | ||
| 114 | { | ||
| 115 | ✗ | throw_exception( | |
| 116 | ✗ | system::system_error(e), loc); | |
| 117 | } | ||
| 118 | |||
| 119 | } // detail | ||
| 120 | } // http | ||
| 121 | } // boost | ||
| 122 |