add to_human_string (#1467)

* add to_human_string

* replace to_string with to_human_string

* fix test
This commit is contained in:
Ray Beck 2023-01-19 07:01:34 -05:00 committed by GitHub
parent 7992b14896
commit 51607ec752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View file

@ -1665,20 +1665,20 @@ Server::set_idle_interval(const std::chrono::duration<Rep, Period> &duration) {
inline std::string to_string(const Error error) { inline std::string to_string(const Error error) {
switch (error) { switch (error) {
case Error::Success: return "Success"; case Error::Success: return "Success (no error)";
case Error::Connection: return "Connection"; case Error::Connection: return "Could not establish connection";
case Error::BindIPAddress: return "BindIPAddress"; case Error::BindIPAddress: return "Failed to bind IP address";
case Error::Read: return "Read"; case Error::Read: return "Failed to read connection";
case Error::Write: return "Write"; case Error::Write: return "Failed to write connection";
case Error::ExceedRedirectCount: return "ExceedRedirectCount"; case Error::ExceedRedirectCount: return "Maximum redirect count exceeded";
case Error::Canceled: return "Canceled"; case Error::Canceled: return "Connection handling canceled";
case Error::SSLConnection: return "SSLConnection"; case Error::SSLConnection: return "SSL connection failed";
case Error::SSLLoadingCerts: return "SSLLoadingCerts"; case Error::SSLLoadingCerts: return "SSL certificate loading failed";
case Error::SSLServerVerification: return "SSLServerVerification"; case Error::SSLServerVerification: return "SSL server verification failed";
case Error::UnsupportedMultipartBoundaryChars: case Error::UnsupportedMultipartBoundaryChars:
return "UnsupportedMultipartBoundaryChars"; return "Unsupported HTTP multipart boundary characters";
case Error::Compression: return "Compression"; case Error::Compression: return "Compression failed";
case Error::ConnectionTimeout: return "ConnectionTimeout"; case Error::ConnectionTimeout: return "Connection timed out";
case Error::Unknown: return "Unknown"; case Error::Unknown: return "Unknown";
default: break; default: break;
} }

View file

@ -596,7 +596,7 @@ TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
ASSERT_TRUE(!res); ASSERT_TRUE(!res);
stringstream s; stringstream s;
s << "error code: " << res.error(); s << "error code: " << res.error();
EXPECT_EQ("error code: Connection (2)", s.str()); EXPECT_EQ("error code: Could not establish connection (2)", s.str());
} }
TEST(ConnectionErrorTest, InvalidPort) { TEST(ConnectionErrorTest, InvalidPort) {