Thrift: Fix dangling pointer errors and make messages a bit more uniform.
Reviewed By: mcslee
Test Plan: Honestly, just built the library.
Revert Plan: ok
Other Notes:
Thanks to Ben Maurer.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665392 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/protocol/TProtocolException.h b/lib/cpp/src/protocol/TProtocolException.h
index 2d542a0..4429a62 100644
--- a/lib/cpp/src/protocol/TProtocolException.h
+++ b/lib/cpp/src/protocol/TProtocolException.h
@@ -66,8 +66,15 @@
virtual const char* what() const throw() {
if (message_.empty()) {
- return (std::string("Default Protocol Exception: ") +
- boost::lexical_cast<std::string>(type_)).c_str();
+ switch (type_) {
+ case UNKNOWN : return "TProtocolException: Unknown protocol exception";
+ case INVALID_DATA : return "TProtocolException: Invalid data";
+ case NEGATIVE_SIZE : return "TProtocolException: Negative size";
+ case SIZE_LIMIT : return "TProtocolException: Exceeded size limit";
+ case BAD_VERSION : return "TProtocolException: Invalid version";
+ case NOT_IMPLEMENTED : return "TProtocolException: Not implemented";
+ default : return "TProtocolException: (Invalid exception type)";
+ }
} else {
return message_.c_str();
}