@@ -224,6 +224,44 @@ void makeDeconfigure(bmqp_ctrlmsg::ControlMessage* request)
224224 }
225225}
226226
227+ // / @brief This function translates other result code types into the
228+ // / less-specific StatusCategory error code.
229+ bmqp_ctrlmsg::StatusCategory::Value intoStatusCategory (int res)
230+ {
231+ switch (res) {
232+ case bmqt::GenericResult::e_SUCCESS: {
233+ return bmqp_ctrlmsg::StatusCategory::E_SUCCESS;
234+ } break ;
235+ case bmqt::GenericResult::e_UNKNOWN: {
236+ return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN;
237+ } break ;
238+ case bmqt::GenericResult::e_TIMEOUT: {
239+ return bmqp_ctrlmsg::StatusCategory::E_TIMEOUT;
240+ } break ;
241+ case bmqt::GenericResult::e_NOT_CONNECTED: {
242+ return bmqp_ctrlmsg::StatusCategory::E_NOT_CONNECTED;
243+ } break ;
244+ case bmqt::GenericResult::e_CANCELED: {
245+ return bmqp_ctrlmsg::StatusCategory::E_CANCELED;
246+ } break ;
247+ case bmqt::GenericResult::e_NOT_SUPPORTED: {
248+ return bmqp_ctrlmsg::StatusCategory::E_NOT_SUPPORTED;
249+ } break ;
250+ case bmqt::GenericResult::e_REFUSED: {
251+ return bmqp_ctrlmsg::StatusCategory::E_REFUSED;
252+ } break ;
253+ case bmqt::GenericResult::e_INVALID_ARGUMENT: {
254+ return bmqp_ctrlmsg::StatusCategory::E_INVALID_ARGUMENT;
255+ } break ;
256+ case bmqt::GenericResult::e_NOT_READY: {
257+ return bmqp_ctrlmsg::StatusCategory::E_NOT_READY;
258+ } break ;
259+ default : {
260+ return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN;
261+ } break ;
262+ }
263+ }
264+
227265} // close unnamed namespace
228266
229267// ------------
@@ -1013,7 +1051,7 @@ void BrokerSession::QueueFsm::setQueueId(
10131051
10141052void BrokerSession::QueueFsm::injectErrorResponse (
10151053 const RequestManagerType::RequestSp& context,
1016- bmqp_ctrlmsg::StatusCategory::Value status,
1054+ int status,
10171055 const bslstl::StringRef& reason)
10181056{
10191057 // executed by the FSM thread
@@ -1022,7 +1060,7 @@ void BrokerSession::QueueFsm::injectErrorResponse(
10221060
10231061 // Inject an error response which will be handled outside the Queue FSM
10241062 bmqp::ControlMessageUtil::makeStatus (&context->response (),
1025- status,
1063+ intoStatusCategory ( status) ,
10261064 status,
10271065 reason);
10281066}
@@ -1526,10 +1564,7 @@ bmqt::OpenQueueResult::Enum BrokerSession::QueueFsm::handleOpenRequest(
15261564 context,
15271565 timeout);
15281566 if (rc != bmqt::OpenQueueResult::e_SUCCESS) {
1529- handleRequestNotSent (
1530- queue,
1531- context,
1532- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
1567+ handleRequestNotSent (queue, context, rc);
15331568 }
15341569
15351570 // Return SUCCESS result. Any error will be reported through the
@@ -1564,7 +1599,7 @@ bmqt::OpenQueueResult::Enum BrokerSession::QueueFsm::handleOpenRequest(
15641599void BrokerSession::QueueFsm::handleRequestNotSent (
15651600 const bsl::shared_ptr<Queue>& queue,
15661601 const RequestManagerType::RequestSp& context,
1567- bmqp_ctrlmsg::StatusCategory::Value status)
1602+ int status)
15681603{
15691604 // executed by the FSM thread
15701605
@@ -1769,10 +1804,7 @@ void BrokerSession::QueueFsm::handleReopenRequest(
17691804 context,
17701805 timeout);
17711806 if (res != bmqt::OpenQueueResult::e_SUCCESS) {
1772- handleRequestNotSent (
1773- queue,
1774- context,
1775- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(res));
1807+ handleRequestNotSent (queue, context, res);
17761808 }
17771809 } break ;
17781810 case QueueState::e_OPENED:
@@ -1930,10 +1962,7 @@ bmqt::CloseQueueResult::Enum BrokerSession::QueueFsm::handleCloseRequest(
19301962 context,
19311963 timeout);
19321964 if (rc != bmqt::ConfigureQueueResult::e_SUCCESS) {
1933- handleRequestNotSent (
1934- queue,
1935- context,
1936- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
1965+ handleRequestNotSent (queue, context, rc);
19371966 }
19381967 } break ;
19391968 case QueueState::e_PENDING: {
@@ -2134,10 +2163,7 @@ void BrokerSession::QueueFsm::handleResponseError(
21342163 absTimeout);
21352164 if (rc != bmqt::GenericResult::e_SUCCESS) {
21362165 // Failed to send close request.
2137- handleRequestNotSent (
2138- queue,
2139- context,
2140- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2166+ handleRequestNotSent (queue, context, rc);
21412167 }
21422168 } break ;
21432169 case QueueState::e_OPENING_OPN_EXPIRED:
@@ -2650,10 +2676,7 @@ void BrokerSession::QueueFsm::handleResponseOk(
26502676 timeout,
26512677 false ); // isReopenRequest
26522678 if (rc != bmqt::ConfigureQueueResult::e_SUCCESS) {
2653- handleRequestNotSent (
2654- queue,
2655- context,
2656- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2679+ handleRequestNotSent (queue, context, rc);
26572680 }
26582681 } break ;
26592682 case QueueState::e_REOPENING_OPN: {
@@ -2691,10 +2714,7 @@ void BrokerSession::QueueFsm::handleResponseOk(
26912714 timeout,
26922715 true ); // isReopenRequest
26932716 if (rc != bmqt::ConfigureQueueResult::e_SUCCESS) {
2694- handleRequestNotSent (
2695- queue,
2696- context,
2697- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2717+ handleRequestNotSent (queue, context, rc);
26982718 }
26992719 } break ;
27002720 case QueueState::e_OPENING_CFG: {
@@ -2746,10 +2766,7 @@ void BrokerSession::QueueFsm::handleResponseOk(
27462766 timeout);
27472767 if (rc != bmqt::GenericResult::e_SUCCESS) {
27482768 // Failed to send close request.
2749- handleRequestNotSent (
2750- queue,
2751- context,
2752- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2769+ handleRequestNotSent (queue, context, rc);
27532770 }
27542771 } break ;
27552772 case QueueState::e_CLOSING_CLS: {
@@ -2837,10 +2854,7 @@ void BrokerSession::QueueFsm::handleLateResponse(
28372854 bmqt::ConfigureQueueResult::Enum rc = actionDeconfigureExpiredQueue (
28382855 queue);
28392856 if (rc != bmqt::ConfigureQueueResult::e_SUCCESS) {
2840- handleRequestNotSent (
2841- queue,
2842- context,
2843- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2857+ handleRequestNotSent (queue, context, rc);
28442858 }
28452859 } break ;
28462860 case QueueState::e_CLOSING_CFG_EXPIRED: {
@@ -2881,10 +2895,7 @@ void BrokerSession::QueueFsm::handleLateResponse(
28812895 bmqt::ConfigureQueueResult::Enum rc =
28822896 actionReconfigureQueue (queue, context->response ());
28832897 if (rc != bmqt::ConfigureQueueResult::e_SUCCESS) {
2884- handleRequestNotSent (
2885- queue,
2886- context,
2887- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc));
2898+ handleRequestNotSent (queue, context, rc);
28882899 }
28892900 } break ;
28902901 case QueueState::e_CLOSING_CFG:
@@ -3274,7 +3285,7 @@ void BrokerSession::asyncRequestNotifier(
32743285 eventCallback);
32753286 }
32763287 else if (context->isError ()) {
3277- bmqt::GenericResult::Enum result = context->result ();
3288+ int result = context->code ();
32783289
32793290 enqueueSessionEvent (eventType,
32803291 result,
@@ -3303,13 +3314,13 @@ void BrokerSession::syncRequestNotifier(
33033314 BSLS_ASSERT_SAFE (semaphore);
33043315 BSLS_ASSERT_SAFE (status);
33053316
3306- bmqt::GenericResult::Enum result = bmqt::GenericResult::e_SUCCESS;
3317+ int result = bmqt::GenericResult::e_SUCCESS;
33073318
33083319 if (!context) {
33093320 result = bmqt::GenericResult::e_REFUSED;
33103321 }
33113322 else if (context->isError ()) {
3312- result = context->result ();
3323+ result = context->code ();
33133324 }
33143325 else {
33153326 result = bmqt::GenericResult::e_SUCCESS;
@@ -4448,7 +4459,7 @@ void BrokerSession::onResumeQueueConfigured(
44484459
44494460 if (queueSp->isOpened () &&
44504461 context->result () != bmqt::GenericResult::e_CANCELED) {
4451- bmqt::GenericResult::Enum status = context->result ();
4462+ int status = context->code ();
44524463
44534464 // We issue two e_QUEUE_RESUMED events in succession.
44544465 // 1. An event with callback attached, which allows PUTs to queue.
@@ -5047,10 +5058,9 @@ void BrokerSession::doOpenQueue(
50475058 // Failure - we still want to notify the user, so we need to "manually"
50485059 // enqueue an event on the event queue.
50495060 // Inject an error response which will be handled outside the Queue FSM
5050- d_queueFsm.injectErrorResponse (
5051- context,
5052- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc),
5053- bmqt::OpenQueueResult::toAscii (rc));
5061+ d_queueFsm.injectErrorResponse (context,
5062+ rc,
5063+ bmqt::OpenQueueResult::toAscii (rc));
50545064
50555065 context->signal ();
50565066}
@@ -5095,10 +5105,9 @@ void BrokerSession::doConfigureQueue(
50955105
50965106 // Failure - we still want to notify the user, so we need to "manually"
50975107 // enqueue an event on the event queue.
5098- d_queueFsm.injectErrorResponse (
5099- context,
5100- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(rc),
5101- bmqt::ConfigureQueueResult::toAscii (rc));
5108+ d_queueFsm.injectErrorResponse (context,
5109+ rc,
5110+ bmqt::ConfigureQueueResult::toAscii (rc));
51025111
51035112 context->signal ();
51045113}
@@ -5132,10 +5141,9 @@ void BrokerSession::doCloseQueue(
51325141 if (res != bmqt::CloseQueueResult::e_SUCCESS) {
51335142 // Failure - we still want to notify the user, so we need to "manually"
51345143 // enqueue an event on the event queue.
5135- d_queueFsm.injectErrorResponse (
5136- closeContext,
5137- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(res),
5138- bmqt::CloseQueueResult::toAscii (res));
5144+ d_queueFsm.injectErrorResponse (closeContext,
5145+ res,
5146+ bmqt::CloseQueueResult::toAscii (res));
51395147 closeContext->signal ();
51405148 }
51415149}
@@ -6471,7 +6479,7 @@ void BrokerSession::onCloseQueueConfigured(
64716479 // Set user response
64726480 d_queueFsm.injectErrorResponse (
64736481 closeQueueContext,
6474- static_cast <bmqp_ctrlmsg::StatusCategory::Value>(result ),
6482+ context-> code ( ),
64756483 " The request was canceled [reason: connection was lost]" );
64766484 }
64776485 else if (configureQueueContext->isLocalTimeout ()) {
0 commit comments