diff options
author | Vijay Pai <vpai@google.com> | 2017-12-19 09:09:52 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-01-08 15:12:55 -0800 |
commit | 9809ce38e9f79b4e9a0b1ec1c076cce0beee1e98 (patch) | |
tree | cc5c3b950d119399570724fa705042a69092257e /include/grpc++ | |
parent | 9427eabf3bf9f1de14a3fabdc72e090dac7601e1 (diff) |
Use appropriate preprocessor guards to allow building without exceptions
Diffstat (limited to 'include/grpc++')
-rw-r--r-- | include/grpc++/impl/codegen/method_handler_impl.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index b72dceb1b4..41c287231f 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -35,15 +35,19 @@ namespace internal { // so this process doesn't require additional overhead in the common case. // Additionally, we don't need to return if we caught an exception or not; // the handling is the same in either case. -template <class F> -Status CatchingFunctionHandler(F&& callable) { +template <class Callable> +Status CatchingFunctionHandler(Callable&& handler) { +#if GRPC_ALLOW_EXCEPTIONS try { - return callable(); + return handler(); } catch (const std::exception& e) { return Status(StatusCode::UNKNOWN, e.what()); } catch (...) { return Status(StatusCode::UNKNOWN, "Exception in method handler"); } +#else + return handler(); +#endif } /// A wrapper class of an application provided rpc method handler. |