Throw exception from inside HttpClientSession.Request().

This commit is contained in:
Chunting Gu
2019-03-08 11:06:19 +08:00
parent 31d0ea3c9d
commit 3647407b8b
8 changed files with 89 additions and 58 deletions
+12
View File
@@ -8,6 +8,8 @@ namespace webcc {
const char* DescribeError(Error error) {
switch (error) {
case kSchemaError:
return "Schema error";
case kHostResolveError:
return "Host resolve error";
case kEndpointConnectError:
@@ -29,4 +31,14 @@ const char* DescribeError(Error error) {
}
}
Exception::Exception(Error error, bool timeout, const std::string& details)
: error_(error), timeout_(timeout), msg_(DescribeError(error)) {
if (timeout) {
msg_ += " (timeout)";
}
if (!details.empty()) {
msg_ += " (" + details + ")";
}
}
} // namespace webcc