Skip to content

Commit 43773b9

Browse files
committed
Add the obvious missing constructor from a std::error_code and 'what' string message; cf. websocket_exception
1 parent bc77da3 commit 43773b9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Release/include/cpprest/http_msg.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,28 @@ class http_exception : public std::exception
248248
m_msg = m_errorCode.message();
249249
}
250250

251+
/// <summary>
252+
/// Creates an <c>http_exception</c> with from a error code with a category, and a string message.
253+
/// </summary>
254+
/// <param name="errorCode">Error code value.</param>
255+
/// <param name="whatArg">Error message string.</param>
256+
http_exception(std::error_code errorCode, const utility::string_t& whatArg)
257+
: m_errorCode(std::move(errorCode)), m_msg(utility::conversions::to_utf8string(whatArg))
258+
{
259+
}
260+
261+
#ifdef _WIN32
262+
/// <summary>
263+
/// Creates an <c>http_exception</c> with from a error code with a category, and a string message.
264+
/// </summary>
265+
/// <param name="errorCode">Error code value.</param>
266+
/// <param name="whatArg">Error message string.</param>
267+
http_exception(std::error_code errorCode, std::string whatArg)
268+
: m_errorCode(std::move(errorCode)), m_msg(std::move(whatArg))
269+
{
270+
}
271+
#endif
272+
251273
/// <summary>
252274
/// Gets a string identifying the cause of the exception.
253275
/// </summary>

0 commit comments

Comments
 (0)