Skip to content

Commit 93c3066

Browse files
committed
refactor: rename namespace to errors
1 parent bd0a07d commit 93c3066

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

include/errors/error.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <string>
77
#include <utility>
88

9-
namespace error {
9+
namespace errors {
1010

1111
/**
1212
* @brief Represents error information.
@@ -32,7 +32,7 @@ struct Error {
3232
* std::cout << err << std::endl;
3333
* @endcode
3434
*/
35-
friend std::ostream& operator<<(std::ostream& os, const error::Error& err);
35+
friend std::ostream& operator<<(std::ostream& os, const errors::Error& err);
3636

3737
/**
3838
* @brief Checks if two error objects are equal.
@@ -85,14 +85,14 @@ Error make(const std::string& msg);
8585
*/
8686
template <typename... T>
8787
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)...));
8989
}
9090

9191
} // namespace error
9292

9393
template <>
94-
struct fmt::formatter<error::Error> {
94+
struct fmt::formatter<errors::Error> {
9595
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,
9797
format_context& ctx) const;
9898
};

src/error.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <errors/error.hpp>
22

3-
namespace error {
3+
namespace errors {
44

5-
std::ostream& operator<<(std::ostream& os, const error::Error& err) {
5+
std::ostream& operator<<(std::ostream& os, const errors::Error& err) {
66
return os << "error: " << err.message;
77
}
88

@@ -20,13 +20,13 @@ Error make(const std::string& msg) { return Error{.message = msg}; }
2020

2121
namespace fmt {
2222

23-
format_parse_context::iterator formatter<error::Error>::parse(
23+
format_parse_context::iterator formatter<errors::Error>::parse(
2424
format_parse_context& ctx) const {
2525
return ctx.begin();
2626
}
2727

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 {
3030
return format_to(ctx.out(), "error: {}", err.message);
3131
}
3232

test/error_test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66
#include <string>
77

88
TEST_CASE("Error Construction") {
9-
const error::Error err = error::make("unknown error");
9+
const errors::Error err = errors::make("unknown error");
1010
REQUIRE(err.message == "unknown error");
1111
}
1212

1313
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);
1515
REQUIRE(err.message == "HTTP error 404");
1616
}
1717

1818
TEST_CASE("Error Comparison") {
19-
const auto err = error::make("unknown error");
19+
const auto err = errors::make("unknown error");
2020
const auto err_copy = err;
2121
CHECK(err == err_copy);
2222
CHECK_FALSE(err != err_copy);
23-
const auto other_err = error::make("other error");
23+
const auto other_err = errors::make("other error");
2424
CHECK_FALSE(err == other_err);
2525
CHECK(err != other_err);
2626
}
2727

2828
TEST_CASE("Error Printing") {
29-
const auto err = error::make("unknown error");
29+
const auto err = errors::make("unknown error");
3030

3131
SECTION("Using ostream") {
3232
const auto ss = std::stringstream() << err;

0 commit comments

Comments
 (0)