THRIFT-1222 Unhandled exception for TEvhttpServer request
Patch: Alexandre Parenteau
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1147542 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/async/TEvhttpServer.cpp b/lib/cpp/src/async/TEvhttpServer.cpp
index 2997597..30e33e5 100644
--- a/lib/cpp/src/async/TEvhttpServer.cpp
+++ b/lib/cpp/src/async/TEvhttpServer.cpp
@@ -22,6 +22,10 @@
#include "transport/TBufferTransports.h"
#include <evhttp.h>
+#ifndef HTTP_INTERNAL // libevent < 2
+#define HTTP_INTERNAL 500
+#endif
+
using apache::thrift::transport::TMemoryBuffer;
namespace apache { namespace thrift { namespace async {
@@ -98,7 +102,11 @@
void TEvhttpServer::request(struct evhttp_request* req, void* self) {
- static_cast<TEvhttpServer*>(self)->process(req);
+ try {
+ static_cast<TEvhttpServer*>(self)->process(req);
+ } catch(std::exception& e) {
+ evhttp_send_reply(req, HTTP_INTERNAL, e.what(), 0);
+ }
}