Enforce rule 15.1 of the High Integrity C++ Coding Standard

See https://www.perforce.com/resources/qac/high-integrity-c-coding-standard-exception-handling
This commit is contained in:
Carles Fernandez 2019-07-30 12:51:36 +02:00
parent 9b4597572c
commit cc54b4a122
5 changed files with 9 additions and 6 deletions

View File

@ -12,6 +12,7 @@ Checks: '-*,
cppcoreguidelines-slicing,
google-build-namespaces,
google-runtime-int,
hicpp-exception-baseclass,
misc-misplaced-const,
misc-new-delete-overloads,
misc-non-copyable-objects,

View File

@ -32,6 +32,7 @@
#include "tcp_communication.h"
#include "tcp_packet_data.h"
#include <iostream>
#include <stdexcept>
#include <string>
@ -87,7 +88,7 @@ void Tcp_Communication::send_receive_tcp_packet_galileo_e1(boost::array<float, N
//! Control. The GNSS-SDR program ends if an error in a TCP packet is detected.
if (d_control_id_ != readbuf.data()[0])
{
throw "Packet error!";
throw std::runtime_error("Packet error!");
}
// Recover the variables received
@ -122,7 +123,7 @@ void Tcp_Communication::send_receive_tcp_packet_gps_l1_ca(boost::array<float, NU
//! Control. The GNSS-SDR program ends if an error in a TCP packet is detected.
if (d_control_id_ != readbuf.data()[0])
{
throw "Packet error!";
throw std::runtime_error("Packet error!");
}
// Recover the variables received

View File

@ -45,6 +45,7 @@
#include <cmath>
#include <iostream> // for operator<<
#include <map>
#include <stdexcept>
#include <utility>
extern Concurrent_Map<Gps_Ephemeris> global_gps_ephemeris_map;
@ -303,7 +304,7 @@ arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, const
}
double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height)
double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false)
{
int num_secs = 10;
double step_secs = 0.5;
@ -359,7 +360,7 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub
mean_Doppler_Hz = arma::mean(Doppler_Hz);
return mean_Doppler_Hz;
}
throw(1);
throw std::runtime_error("1");
}

View File

@ -65,7 +65,7 @@ public:
* 3- Approximate receiver Latitude and Longitude (WGS-84)
*
*/
double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height);
double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false);
/*!
* \brief This function models the Elonics E4000 + RTL2832 front-end

View File

@ -574,7 +574,7 @@ int main(int argc, char** argv)
{
std::cout << "Exception caught while reading ephemeris" << std::endl;
}
catch (int ex)
catch (const std::exception& ex)
{
std::cout << " " << it.first << " " << it.second << " (Eph not found)" << std::endl;
}