# HG changeset patch # User rubidium42 # Date 2021-06-13 19:41:07 # Node ID fb6d0e17cffc6771f99938117ef62895ed1a7316 # Parent 28affbeede234c860b0e8e9edda6e3bb7bf020c3 Codechange: [Network] Let NetworkError return its std::string instead of a C-string diff --git a/src/network/core/os_abstraction.cpp b/src/network/core/os_abstraction.cpp --- a/src/network/core/os_abstraction.cpp +++ b/src/network/core/os_abstraction.cpp @@ -76,7 +76,7 @@ bool NetworkError::IsConnectInProgress() * Get the string representation of the error message. * @return The string representation that will get overwritten by next calls. */ -const char *NetworkError::AsString() const +const std::string &NetworkError::AsString() const { if (this->message.empty()) { #if defined(_WIN32) @@ -97,7 +97,7 @@ const char *NetworkError::AsString() con this->message.assign(strerror(this->error)); #endif } - return this->message.c_str(); + return this->message; } /** diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h --- a/src/network/core/os_abstraction.h +++ b/src/network/core/os_abstraction.h @@ -29,7 +29,7 @@ public: bool WouldBlock() const; bool IsConnectionReset() const; bool IsConnectInProgress() const; - const char *AsString() const; + const std::string &AsString() const; static NetworkError GetLast(); };