/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/exceptions/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #pragma once #include "thrift/compiler/test/fixtures/exceptions/gen-cpp2/Raiser.h" #include namespace cpp2 { typedef apache::thrift::ThriftPresult Raiser_doBland_pargs; typedef apache::thrift::ThriftPresult Raiser_doBland_presult; typedef apache::thrift::ThriftPresult Raiser_doRaise_pargs; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<2, ::apache::thrift::type_class::structure, ::cpp2::Fiery>, apache::thrift::FieldData<3, ::apache::thrift::type_class::structure, ::cpp2::Serious>> Raiser_doRaise_presult; typedef apache::thrift::ThriftPresult Raiser_get200_pargs; typedef apache::thrift::ThriftPresult> Raiser_get200_presult; typedef apache::thrift::ThriftPresult Raiser_get500_pargs; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::Fiery>, apache::thrift::FieldData<2, ::apache::thrift::type_class::structure, ::cpp2::Banal>, apache::thrift::FieldData<3, ::apache::thrift::type_class::structure, ::cpp2::Serious>> Raiser_get500_presult; template void RaiserAsyncProcessor::setUpAndProcess_doBland(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &RaiserAsyncProcessor::executeRequest_doBland, this); } template void RaiserAsyncProcessor::executeRequest_doBland(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { Raiser_doBland_pargs pargs() { Raiser_doBland_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "Raiser.doBland", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "doBland", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "doBland"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "doBland" , return_doBland , throw_wrapped_doBland , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_doBland(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template apache::thrift::SerializedResponse RaiserAsyncProcessor::return_doBland(apache::thrift::ContextStack* ctx) { ProtocolOut_ prot; ::cpp2::Raiser_doBland_presult result; return serializeResponse("doBland", &prot, ctx, result); } template void RaiserAsyncProcessor::throw_wrapped_doBland(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "doBland"); return; } } template void RaiserAsyncProcessor::setUpAndProcess_doRaise(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &RaiserAsyncProcessor::executeRequest_doRaise, this); } template void RaiserAsyncProcessor::executeRequest_doRaise(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { Raiser_doRaise_pargs pargs() { Raiser_doRaise_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "Raiser.doRaise", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "doRaise", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "doRaise"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "doRaise" , return_doRaise , throw_wrapped_doRaise , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_doRaise(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template apache::thrift::SerializedResponse RaiserAsyncProcessor::return_doRaise(apache::thrift::ContextStack* ctx) { ProtocolOut_ prot; ::cpp2::Raiser_doRaise_presult result; return serializeResponse("doRaise", &prot, ctx, result); } template void RaiserAsyncProcessor::throw_wrapped_doRaise(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } ::cpp2::Raiser_doRaise_presult result; if (ew.with_exception([&]( ::cpp2::Banal& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Banal>(ew, *reqCtx); result.get<0>().ref() = e; result.setIsSet(0, true); } )) {} else if (ew.with_exception([&]( ::cpp2::Fiery& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Fiery>(ew, *reqCtx); result.get<1>().ref() = e; result.setIsSet(1, true); } )) {} else if (ew.with_exception([&]( ::cpp2::Serious& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Serious>(ew, *reqCtx); result.get<2>().ref() = e; result.setIsSet(2, true); } )) {} else { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "doRaise"); return; } ProtocolOut_ prot; auto response = serializeResponse("doRaise", &prot, ctx, result); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "doRaise"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); return req->sendReply(std::move(payload)); } template void RaiserAsyncProcessor::setUpAndProcess_get200(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &RaiserAsyncProcessor::executeRequest_get200, this); } template void RaiserAsyncProcessor::executeRequest_get200(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { Raiser_get200_pargs pargs() { Raiser_get200_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "Raiser.get200", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "get200", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "get200"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "get200" , return_get200 , throw_wrapped_get200 , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_get200(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template apache::thrift::SerializedResponse RaiserAsyncProcessor::return_get200(apache::thrift::ContextStack* ctx, ::std::string const& _return) { ProtocolOut_ prot; ::cpp2::Raiser_get200_presult result; result.get<0>().value = const_cast<::std::string*>(&_return); result.setIsSet(0, true); return serializeResponse("get200", &prot, ctx, result); } template void RaiserAsyncProcessor::throw_wrapped_get200(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "get200"); return; } } template void RaiserAsyncProcessor::setUpAndProcess_get500(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &RaiserAsyncProcessor::executeRequest_get500, this); } template void RaiserAsyncProcessor::executeRequest_get500(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { Raiser_get500_pargs pargs() { Raiser_get500_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "Raiser.get500", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "get500", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "get500"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "get500" , return_get500 , throw_wrapped_get500 , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_get500(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template apache::thrift::SerializedResponse RaiserAsyncProcessor::return_get500(apache::thrift::ContextStack* ctx, ::std::string const& _return) { ProtocolOut_ prot; ::cpp2::Raiser_get500_presult result; result.get<0>().value = const_cast<::std::string*>(&_return); result.setIsSet(0, true); return serializeResponse("get500", &prot, ctx, result); } template void RaiserAsyncProcessor::throw_wrapped_get500(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } ::cpp2::Raiser_get500_presult result; if (ew.with_exception([&]( ::cpp2::Fiery& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Fiery>(ew, *reqCtx); result.get<1>().ref() = e; result.setIsSet(1, true); } )) {} else if (ew.with_exception([&]( ::cpp2::Banal& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Banal>(ew, *reqCtx); result.get<2>().ref() = e; result.setIsSet(2, true); } )) {} else if (ew.with_exception([&]( ::cpp2::Serious& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::Serious>(ew, *reqCtx); result.get<3>().ref() = e; result.setIsSet(3, true); } )) {} else { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "get500"); return; } ProtocolOut_ prot; auto response = serializeResponse("get500", &prot, ctx, result); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "get500"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); return req->sendReply(std::move(payload)); } } // namespace cpp2