in mcrouter/lib/network/ThriftTransport-inl.h [37:98]
FOLLY_NOINLINE auto ThriftTransportBase::makeError(
const ConnectionState oldState,
const folly::exception_wrapper& ew) {
T reply;
if (ew.with_exception([&](const apache::thrift::transport::
TTransportException& tex) {
carbon::Result res;
switch (tex.getType()) {
case apache::thrift::transport::TTransportException::NOT_OPEN:
if ((oldState == ConnectionState::Down ||
oldState == ConnectionState::Connecting) &&
connectionTimedOut_) {
res = carbon::Result::CONNECT_TIMEOUT;
} else if (oldState == ConnectionState::Up) {
res = carbon::Result::REMOTE_ERROR;
} else {
res = carbon::Result::CONNECT_ERROR;
}
break;
case apache::thrift::transport::TTransportException::END_OF_FILE:
if (oldState == ConnectionState::Down ||
oldState == ConnectionState::Connecting) {
res = carbon::Result::CONNECT_ERROR;
} else {
res = carbon::Result::REMOTE_ERROR;
}
break;
case apache::thrift::transport::TTransportException::TIMED_OUT:
res = carbon::Result::TIMEOUT;
break;
case apache::thrift::transport::TTransportException::NETWORK_ERROR:
res = carbon::Result::LOCAL_ERROR;
break;
case apache::thrift::transport::TTransportException::INTERRUPTED:
res = carbon::Result::ABORTED;
break;
case apache::thrift::transport::TTransportException::ALREADY_OPEN:
case apache::thrift::transport::TTransportException::SSL_ERROR:
case apache::thrift::transport::TTransportException::COULD_NOT_BIND:
default:
// Using local_error as the default error now for a lack of better
// options.
res = carbon::Result::LOCAL_ERROR;
}
setReplyResultAndMessage(reply, res, tex.what());
})) {
} else if (ew.with_exception(
[&](const apache::thrift::TApplicationException& ex) {
carbon::Result res = carbon::Result::REMOTE_ERROR;
if (ex.getType() ==
apache::thrift::TApplicationException::LOADSHEDDING) {
res = carbon::Result::RES_TRY_AGAIN;
}
setReplyResultAndMessage(reply, res, ex.what());
})) {
} else if (ew.with_exception([&](const std::exception& e) {
setReplyResultAndMessage(
reply, carbon::Result::LOCAL_ERROR, e.what());
})) {
}
return reply;
}