diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index d1a74600a..a06a5d424 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -1146,6 +1146,8 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGErrorResponse& error) { + error.init(); + if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size())) { DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex]; @@ -1156,7 +1158,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1174,7 +1175,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1188,14 +1188,12 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( } else { - error.init(); *error.getMessage() = QString("DeviceSet error"); return 500; } } else { - error.init(); *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); return 404; } @@ -1209,6 +1207,8 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGErrorResponse& error) { + error.init(); + if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size())) { DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex]; @@ -1219,7 +1219,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1234,7 +1233,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") .arg(*response.getChannelType()) .arg(channelIndex) @@ -1249,7 +1247,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1264,7 +1261,6 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") .arg(*response.getChannelType()) .arg(channelIndex) @@ -1275,16 +1271,13 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("DeviceSet error"); return 500; } } else { - error.init(); *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); - return 404; } diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index e192261e9..7b46d88e4 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -1251,6 +1251,8 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet( SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGErrorResponse& error) { + error.init(); + if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) { DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; @@ -1261,7 +1263,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1279,7 +1280,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1293,14 +1293,12 @@ int WebAPIAdapterSrv::devicesetChannelSettingsGet( } else { - error.init(); *error.getMessage() = QString("DeviceSet error"); return 500; } } else { - error.init(); *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); return 404; } @@ -1314,6 +1312,8 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGErrorResponse& error) { + error.init(); + if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size())) { DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex]; @@ -1324,7 +1324,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1339,7 +1338,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") .arg(*response.getChannelType()) .arg(channelIndex) @@ -1354,7 +1352,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( if (channelAPI == 0) { - error.init(); *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); return 404; } @@ -1369,7 +1366,6 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.") .arg(*response.getChannelType()) .arg(channelIndex) @@ -1380,19 +1376,15 @@ int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch( } else { - error.init(); *error.getMessage() = QString("DeviceSet error"); return 500; } } else { - error.init(); *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); - return 404; } - } void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)