@@ -170,9 +170,17 @@ void getCfgSwitchType(DBConnector *cfgDb, string &switch_type)
170
170
{
171
171
Table cfgDeviceMetaDataTable (cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
172
172
173
- if (!cfgDeviceMetaDataTable. hget ( " localhost " , " switch_type " , switch_type))
173
+ try
174
174
{
175
- // Switch type is not configured. Consider it default = "switch" (regular switch)
175
+ if (!cfgDeviceMetaDataTable.hget (" localhost" , " switch_type" , switch_type))
176
+ {
177
+ // Switch type is not configured. Consider it default = "switch" (regular switch)
178
+ switch_type = " switch" ;
179
+ }
180
+ }
181
+ catch (const std::system_error& e)
182
+ {
183
+ SWSS_LOG_ERROR (" System error: %s" , e.what ());
176
184
switch_type = " switch" ;
177
185
}
178
186
@@ -196,64 +204,72 @@ bool getSystemPortConfigList(DBConnector *cfgDb, DBConnector *appDb, vector<sai_
196
204
return true ;
197
205
}
198
206
199
- string value;
200
- if (!cfgDeviceMetaDataTable.hget (" localhost" , " switch_id" , value))
207
+ try
201
208
{
202
- // VOQ switch id is not configured.
203
- SWSS_LOG_ERROR (" VOQ switch id is not configured" );
204
- return false ;
205
- }
209
+ string value;
210
+ if (!cfgDeviceMetaDataTable.hget (" localhost" , " switch_id" , value))
211
+ {
212
+ // VOQ switch id is not configured.
213
+ SWSS_LOG_ERROR (" VOQ switch id is not configured" );
214
+ return false ;
215
+ }
206
216
207
- if (value.size ())
208
- gVoqMySwitchId = stoi (value);
217
+ if (value.size ())
218
+ gVoqMySwitchId = stoi (value);
209
219
210
- if (gVoqMySwitchId < 0 )
211
- {
212
- SWSS_LOG_ERROR (" Invalid VOQ switch id %d configured" , gVoqMySwitchId );
213
- return false ;
214
- }
220
+ if (gVoqMySwitchId < 0 )
221
+ {
222
+ SWSS_LOG_ERROR (" Invalid VOQ switch id %d configured" , gVoqMySwitchId );
223
+ return false ;
224
+ }
215
225
216
- if (!cfgDeviceMetaDataTable.hget (" localhost" , " max_cores" , value))
217
- {
218
- // VOQ max cores is not configured.
219
- SWSS_LOG_ERROR (" VOQ max cores is not configured" );
220
- return false ;
221
- }
226
+ if (!cfgDeviceMetaDataTable.hget (" localhost" , " max_cores" , value))
227
+ {
228
+ // VOQ max cores is not configured.
229
+ SWSS_LOG_ERROR (" VOQ max cores is not configured" );
230
+ return false ;
231
+ }
222
232
223
- if (value.size ())
224
- gVoqMaxCores = stoi (value);
233
+ if (value.size ())
234
+ gVoqMaxCores = stoi (value);
225
235
226
- if (gVoqMaxCores == 0 )
227
- {
228
- SWSS_LOG_ERROR (" Invalid VOQ max cores %d configured" , gVoqMaxCores );
229
- return false ;
230
- }
236
+ if (gVoqMaxCores == 0 )
237
+ {
238
+ SWSS_LOG_ERROR (" Invalid VOQ max cores %d configured" , gVoqMaxCores );
239
+ return false ;
240
+ }
231
241
232
- if (!cfgDeviceMetaDataTable.hget (" localhost" , " hostname" , value))
233
- {
234
- // hostname is not configured.
235
- SWSS_LOG_ERROR (" Host name is not configured" );
236
- return false ;
237
- }
238
- gMyHostName = value;
242
+ if (!cfgDeviceMetaDataTable.hget (" localhost" , " hostname" , value))
243
+ {
244
+ // hostname is not configured.
245
+ SWSS_LOG_ERROR (" Host name is not configured" );
246
+ return false ;
247
+ }
248
+ gMyHostName = value;
239
249
240
- if (!gMyHostName .size ())
241
- {
242
- SWSS_LOG_ERROR (" Invalid host name %s configured" , gMyHostName .c_str ());
243
- return false ;
244
- }
250
+ if (!gMyHostName .size ())
251
+ {
252
+ SWSS_LOG_ERROR (" Invalid host name %s configured" , gMyHostName .c_str ());
253
+ return false ;
254
+ }
245
255
246
- if (!cfgDeviceMetaDataTable.hget (" localhost" , " asic_name" , value))
247
- {
248
- // asic_name is not configured.
249
- SWSS_LOG_ERROR (" Asic name is not configured" );
250
- return false ;
251
- }
252
- gMyAsicName = value;
256
+ if (!cfgDeviceMetaDataTable.hget (" localhost" , " asic_name" , value))
257
+ {
258
+ // asic_name is not configured.
259
+ SWSS_LOG_ERROR (" Asic name is not configured" );
260
+ return false ;
261
+ }
262
+ gMyAsicName = value;
253
263
254
- if (!gMyAsicName .size ())
264
+ if (!gMyAsicName .size ())
265
+ {
266
+ SWSS_LOG_ERROR (" Invalid asic name %s configured" , gMyAsicName .c_str ());
267
+ return false ;
268
+ }
269
+ }
270
+ catch (const std::system_error& e)
255
271
{
256
- SWSS_LOG_ERROR (" Invalid asic name %s configured " , gMyAsicName . c_str ());
272
+ SWSS_LOG_ERROR (" System error: %s " , e. what ());
257
273
return false ;
258
274
}
259
275
0 commit comments