@@ -328,7 +328,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
328328 if (status != SAI_STATUS_SUCCESS)
329329 {
330330 SWSS_LOG_ERROR (" Failed to get CPU port, rv:%d" , status);
331- throw runtime_error (" PortsOrch initialization failure" );
331+ task_process_status handle_status = handleSaiGetStatus (SAI_API_SWITCH, status);
332+ if (handle_status != task_process_status::task_success)
333+ {
334+ throw runtime_error (" PortsOrch initialization failure" );
335+ }
332336 }
333337
334338 m_cpuPort = Port (" CPU" , Port::CPU);
@@ -343,7 +347,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
343347 if (status != SAI_STATUS_SUCCESS)
344348 {
345349 SWSS_LOG_ERROR (" Failed to get port number, rv:%d" , status);
346- throw runtime_error (" PortsOrch initialization failure" );
350+ task_process_status handle_status = handleSaiGetStatus (SAI_API_SWITCH, status);
351+ if (handle_status != task_process_status::task_success)
352+ {
353+ throw runtime_error (" PortsOrch initialization failure" );
354+ }
347355 }
348356
349357 m_portCount = attr.value .u32 ;
@@ -361,7 +369,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
361369 if (status != SAI_STATUS_SUCCESS)
362370 {
363371 SWSS_LOG_ERROR (" Failed to get port list, rv:%d" , status);
364- throw runtime_error (" PortsOrch initialization failure" );
372+ task_process_status handle_status = handleSaiGetStatus (SAI_API_SWITCH, status);
373+ if (handle_status != task_process_status::task_success)
374+ {
375+ throw runtime_error (" PortsOrch initialization failure" );
376+ }
365377 }
366378
367379 /* Get port hardware lane info */
@@ -376,7 +388,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
376388 if (status != SAI_STATUS_SUCCESS)
377389 {
378390 SWSS_LOG_ERROR (" Failed to get hardware lane list pid:%" PRIx64, port_list[i]);
379- throw runtime_error (" PortsOrch initialization failure" );
391+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
392+ if (handle_status != task_process_status::task_success)
393+ {
394+ throw runtime_error (" PortsOrch initialization failure" );
395+ }
380396 }
381397
382398 set<int > tmp_lane_set;
@@ -407,7 +423,11 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
407423 if (status != SAI_STATUS_SUCCESS)
408424 {
409425 SWSS_LOG_ERROR (" Failed to get default 1Q bridge and/or default VLAN, rv:%d" , status);
410- throw runtime_error (" PortsOrch initialization failure" );
426+ task_process_status handle_status = handleSaiGetStatus (SAI_API_SWITCH, status);
427+ if (handle_status != task_process_status::task_success)
428+ {
429+ throw runtime_error (" PortsOrch initialization failure" );
430+ }
411431 }
412432
413433 m_default1QBridge = attrs[0 ].value .oid ;
@@ -437,7 +457,11 @@ void PortsOrch::removeDefaultVlanMembers()
437457 if (status != SAI_STATUS_SUCCESS)
438458 {
439459 SWSS_LOG_ERROR (" Failed to get VLAN member list in default VLAN, rv:%d" , status);
440- throw runtime_error (" PortsOrch initialization failure" );
460+ task_process_status handle_status = handleSaiGetStatus (SAI_API_VLAN, status);
461+ if (handle_status != task_process_status::task_success)
462+ {
463+ throw runtime_error (" PortsOrch initialization failure" );
464+ }
441465 }
442466
443467 /* Remove VLAN members in default VLAN */
@@ -471,7 +495,11 @@ void PortsOrch::removeDefaultBridgePorts()
471495 if (status != SAI_STATUS_SUCCESS)
472496 {
473497 SWSS_LOG_ERROR (" Failed to get bridge port list in default 1Q bridge, rv:%d" , status);
474- throw runtime_error (" PortsOrch initialization failure" );
498+ task_process_status handle_status = handleSaiGetStatus (SAI_API_BRIDGE, status);
499+ if (handle_status != task_process_status::task_success)
500+ {
501+ throw runtime_error (" PortsOrch initialization failure" );
502+ }
475503 }
476504
477505 auto bridge_port_count = attr.value .objlist .count ;
@@ -486,7 +514,11 @@ void PortsOrch::removeDefaultBridgePorts()
486514 if (status != SAI_STATUS_SUCCESS)
487515 {
488516 SWSS_LOG_ERROR (" Failed to get bridge port type, rv:%d" , status);
489- throw runtime_error (" PortsOrch initialization failure" );
517+ task_process_status handle_status = handleSaiGetStatus (SAI_API_BRIDGE, status);
518+ if (handle_status != task_process_status::task_success)
519+ {
520+ throw runtime_error (" PortsOrch initialization failure" );
521+ }
490522 }
491523 if (attr.value .s32 == SAI_BRIDGE_PORT_TYPE_PORT)
492524 {
@@ -880,7 +912,11 @@ bool PortsOrch::getPortAdminStatus(sai_object_id_t id, bool &up)
880912 if (status != SAI_STATUS_SUCCESS)
881913 {
882914 SWSS_LOG_ERROR (" Failed to get admin status for port pid:%" PRIx64, id);
883- return false ;
915+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
916+ if (handle_status != task_process_status::task_success)
917+ {
918+ return false ;
919+ }
884920 }
885921
886922 up = attr.value .booldata ;
@@ -1805,9 +1841,19 @@ bool PortsOrch::getPortSpeed(sai_object_id_t id, sai_uint32_t &speed)
18051841 status = sai_port_api->get_port_attribute (id, 1 , &attr);
18061842
18071843 if (status == SAI_STATUS_SUCCESS)
1844+ {
18081845 speed = attr.value .u32 ;
1846+ }
1847+ else
1848+ {
1849+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
1850+ if (handle_status != task_process_status::task_success)
1851+ {
1852+ return false ;
1853+ }
1854+ }
18091855
1810- return status == SAI_STATUS_SUCCESS ;
1856+ return true ;
18111857}
18121858
18131859bool PortsOrch::setPortAdvSpeed (sai_object_id_t port_id, sai_uint32_t speed)
@@ -1847,7 +1893,11 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin
18471893 if (status != SAI_STATUS_SUCCESS)
18481894 {
18491895 SWSS_LOG_ERROR (" Failed to get queue type and index for queue %" PRIu64 " rv:%d" , queue_id, status);
1850- return false ;
1896+ task_process_status handle_status = handleSaiGetStatus (SAI_API_QUEUE, status);
1897+ if (handle_status != task_process_status::task_success)
1898+ {
1899+ return false ;
1900+ }
18511901 }
18521902
18531903 switch (attr[0 ].value .s32 )
@@ -3473,7 +3523,11 @@ void PortsOrch::initializeQueues(Port &port)
34733523 if (status != SAI_STATUS_SUCCESS)
34743524 {
34753525 SWSS_LOG_ERROR (" Failed to get number of queues for port %s rv:%d" , port.m_alias .c_str (), status);
3476- throw runtime_error (" PortsOrch initialization failure." );
3526+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
3527+ if (handle_status != task_process_status::task_success)
3528+ {
3529+ throw runtime_error (" PortsOrch initialization failure." );
3530+ }
34773531 }
34783532 SWSS_LOG_INFO (" Get %d queues for port %s" , attr.value .u32 , port.m_alias .c_str ());
34793533
@@ -3493,7 +3547,11 @@ void PortsOrch::initializeQueues(Port &port)
34933547 if (status != SAI_STATUS_SUCCESS)
34943548 {
34953549 SWSS_LOG_ERROR (" Failed to get queue list for port %s rv:%d" , port.m_alias .c_str (), status);
3496- throw runtime_error (" PortsOrch initialization failure." );
3550+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
3551+ if (handle_status != task_process_status::task_success)
3552+ {
3553+ throw runtime_error (" PortsOrch initialization failure." );
3554+ }
34973555 }
34983556
34993557 SWSS_LOG_INFO (" Get queues for port %s" , port.m_alias .c_str ());
@@ -3509,7 +3567,11 @@ void PortsOrch::initializePriorityGroups(Port &port)
35093567 if (status != SAI_STATUS_SUCCESS)
35103568 {
35113569 SWSS_LOG_ERROR (" Failed to get number of priority groups for port %s rv:%d" , port.m_alias .c_str (), status);
3512- throw runtime_error (" PortsOrch initialization failure." );
3570+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
3571+ if (handle_status != task_process_status::task_success)
3572+ {
3573+ throw runtime_error (" PortsOrch initialization failure." );
3574+ }
35133575 }
35143576 SWSS_LOG_INFO (" Get %d priority groups for port %s" , attr.value .u32 , port.m_alias .c_str ());
35153577
@@ -3530,7 +3592,11 @@ void PortsOrch::initializePriorityGroups(Port &port)
35303592 if (status != SAI_STATUS_SUCCESS)
35313593 {
35323594 SWSS_LOG_ERROR (" Fail to get priority group list for port %s rv:%d" , port.m_alias .c_str (), status);
3533- throw runtime_error (" PortsOrch initialization failure." );
3595+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
3596+ if (handle_status != task_process_status::task_success)
3597+ {
3598+ throw runtime_error (" PortsOrch initialization failure." );
3599+ }
35343600 }
35353601 SWSS_LOG_INFO (" Get priority groups for port %s" , port.m_alias .c_str ());
35363602}
@@ -4844,7 +4910,11 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id,
48444910 {
48454911 SWSS_LOG_ERROR (" Failed to get port attr serdes id %d to port pid:0x%" PRIx64,
48464912 port_attr.id , port_id);
4847- return false ;
4913+ task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
4914+ if (handle_status != task_process_status::task_success)
4915+ {
4916+ return false ;
4917+ }
48484918 }
48494919
48504920 if (port_attr.value .oid != SAI_NULL_OBJECT_ID)
0 commit comments