File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 6
6
#include < string>
7
7
#include < utility>
8
8
9
- namespace error {
9
+ namespace errors {
10
10
11
11
/* *
12
12
* @brief Represents error information.
@@ -32,7 +32,7 @@ struct Error {
32
32
* std::cout << err << std::endl;
33
33
* @endcode
34
34
*/
35
- friend std::ostream& operator <<(std::ostream& os, const error ::Error& err);
35
+ friend std::ostream& operator <<(std::ostream& os, const errors ::Error& err);
36
36
37
37
/* *
38
38
* @brief Checks if two error objects are equal.
@@ -85,14 +85,14 @@ Error make(const std::string& msg);
85
85
*/
86
86
template <typename ... T>
87
87
Error format (fmt::format_string<T...> fmt, T&&... args) {
88
- return error ::make (fmt::format (fmt, std::forward<T>(args)...));
88
+ return errors ::make (fmt::format (fmt, std::forward<T>(args)...));
89
89
}
90
90
91
91
} // namespace error
92
92
93
93
template <>
94
- struct fmt ::formatter<error ::Error> {
94
+ struct fmt ::formatter<errors ::Error> {
95
95
format_parse_context::iterator parse (format_parse_context& ctx) const ;
96
- format_context::iterator format (const error ::Error& err,
96
+ format_context::iterator format (const errors ::Error& err,
97
97
format_context& ctx) const ;
98
98
};
Original file line number Diff line number Diff line change 1
1
#include < errors/error.hpp>
2
2
3
- namespace error {
3
+ namespace errors {
4
4
5
- std::ostream& operator <<(std::ostream& os, const error ::Error& err) {
5
+ std::ostream& operator <<(std::ostream& os, const errors ::Error& err) {
6
6
return os << " error: " << err.message ;
7
7
}
8
8
@@ -20,13 +20,13 @@ Error make(const std::string& msg) { return Error{.message = msg}; }
20
20
21
21
namespace fmt {
22
22
23
- format_parse_context::iterator formatter<error ::Error>::parse(
23
+ format_parse_context::iterator formatter<errors ::Error>::parse(
24
24
format_parse_context& ctx) const {
25
25
return ctx.begin ();
26
26
}
27
27
28
- format_context::iterator formatter<error ::Error>::format(
29
- const error ::Error& err, format_context& ctx) const {
28
+ format_context::iterator formatter<errors ::Error>::format(
29
+ const errors ::Error& err, format_context& ctx) const {
30
30
return format_to (ctx.out (), " error: {}" , err.message );
31
31
}
32
32
Original file line number Diff line number Diff line change 6
6
#include < string>
7
7
8
8
TEST_CASE (" Error Construction" ) {
9
- const error ::Error err = error ::make (" unknown error" );
9
+ const errors ::Error err = errors ::make (" unknown error" );
10
10
REQUIRE (err.message == " unknown error" );
11
11
}
12
12
13
13
TEST_CASE (" Error Construction With Formatting" ) {
14
- const error ::Error err = error ::format (" HTTP error {}" , 404 );
14
+ const errors ::Error err = errors ::format (" HTTP error {}" , 404 );
15
15
REQUIRE (err.message == " HTTP error 404" );
16
16
}
17
17
18
18
TEST_CASE (" Error Comparison" ) {
19
- const auto err = error ::make (" unknown error" );
19
+ const auto err = errors ::make (" unknown error" );
20
20
const auto err_copy = err;
21
21
CHECK (err == err_copy);
22
22
CHECK_FALSE (err != err_copy);
23
- const auto other_err = error ::make (" other error" );
23
+ const auto other_err = errors ::make (" other error" );
24
24
CHECK_FALSE (err == other_err);
25
25
CHECK (err != other_err);
26
26
}
27
27
28
28
TEST_CASE (" Error Printing" ) {
29
- const auto err = error ::make (" unknown error" );
29
+ const auto err = errors ::make (" unknown error" );
30
30
31
31
SECTION (" Using ostream" ) {
32
32
const auto ss = std::stringstream () << err;
You can’t perform that action at this time.
0 commit comments