Skip to content

Commit 51607ec

Browse files
authored
add to_human_string (#1467)
* add to_human_string * replace to_string with to_human_string * fix test
1 parent 7992b14 commit 51607ec

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

httplib.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,20 +1665,20 @@ Server::set_idle_interval(const std::chrono::duration<Rep, Period> &duration) {
16651665

16661666
inline std::string to_string(const Error error) {
16671667
switch (error) {
1668-
case Error::Success: return "Success";
1669-
case Error::Connection: return "Connection";
1670-
case Error::BindIPAddress: return "BindIPAddress";
1671-
case Error::Read: return "Read";
1672-
case Error::Write: return "Write";
1673-
case Error::ExceedRedirectCount: return "ExceedRedirectCount";
1674-
case Error::Canceled: return "Canceled";
1675-
case Error::SSLConnection: return "SSLConnection";
1676-
case Error::SSLLoadingCerts: return "SSLLoadingCerts";
1677-
case Error::SSLServerVerification: return "SSLServerVerification";
1668+
case Error::Success: return "Success (no error)";
1669+
case Error::Connection: return "Could not establish connection";
1670+
case Error::BindIPAddress: return "Failed to bind IP address";
1671+
case Error::Read: return "Failed to read connection";
1672+
case Error::Write: return "Failed to write connection";
1673+
case Error::ExceedRedirectCount: return "Maximum redirect count exceeded";
1674+
case Error::Canceled: return "Connection handling canceled";
1675+
case Error::SSLConnection: return "SSL connection failed";
1676+
case Error::SSLLoadingCerts: return "SSL certificate loading failed";
1677+
case Error::SSLServerVerification: return "SSL server verification failed";
16781678
case Error::UnsupportedMultipartBoundaryChars:
1679-
return "UnsupportedMultipartBoundaryChars";
1680-
case Error::Compression: return "Compression";
1681-
case Error::ConnectionTimeout: return "ConnectionTimeout";
1679+
return "Unsupported HTTP multipart boundary characters";
1680+
case Error::Compression: return "Compression failed";
1681+
case Error::ConnectionTimeout: return "Connection timed out";
16821682
case Error::Unknown: return "Unknown";
16831683
default: break;
16841684
}

test/test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
596596
ASSERT_TRUE(!res);
597597
stringstream s;
598598
s << "error code: " << res.error();
599-
EXPECT_EQ("error code: Connection (2)", s.str());
599+
EXPECT_EQ("error code: Could not establish connection (2)", s.str());
600600
}
601601

602602
TEST(ConnectionErrorTest, InvalidPort) {

0 commit comments

Comments
 (0)