Skip to content

Commit

Permalink
Give more info on exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aang23 committed Mar 14, 2024
1 parent 82d6f4d commit 7c0e2dc
Show file tree
Hide file tree
Showing 67 changed files with 226 additions and 167 deletions.
10 changes: 5 additions & 5 deletions android/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ float funcDeviceScale()

jint jni_return = java_vm->GetEnv((void**)&java_env, JNI_VERSION_1_6);
if (jni_return == JNI_ERR)
throw std::runtime_error("Could not get JNI environement");
throw satdump_exception("Could not get JNI environement");

jni_return = java_vm->AttachCurrentThread(&java_env, NULL);
if (jni_return != JNI_OK)
throw std::runtime_error("Could not attach to thread");
throw satdump_exception("Could not attach to thread");

jclass native_activity_clazz = java_env->GetObjectClass(g_App->activity->clazz);
if (native_activity_clazz == NULL)
throw std::runtime_error("Could not get MainActivity class");
throw satdump_exception("Could not get MainActivity class");

jmethodID method_id = java_env->GetMethodID(native_activity_clazz, "get_dpi", "()F");
if (method_id == NULL)
throw std::runtime_error("Could not get methode ID");
throw satdump_exception("Could not get methode ID");

jfloat jflt = java_env->CallFloatMethod(g_App->activity->clazz, method_id);

jni_return = java_vm->DetachCurrentThread();
if (jni_return != JNI_OK)
throw std::runtime_error("Could not detach from thread");
throw satdump_exception("Could not detach from thread");

return jflt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace noaa_apt
if (parameters.count("audio_samplerate") > 0)
d_audio_samplerate = parameters["audio_samplerate"].get<long>();
else
throw std::runtime_error("Audio samplerate parameter must be present!");
throw satdump_exception("Audio samplerate parameter must be present!");

if (parameters.count("autocrop_wedges") > 0)
d_autocrop_wedges = parameters["autocrop_wedges"].get<bool>();
Expand Down
10 changes: 5 additions & 5 deletions plugins/bochum_support/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ namespace bochum
#if defined(_WIN32)
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
throw std::runtime_error("Couldn't startup WSA socket!");
throw satdump_exception("Couldn't startup WSA socket!");
#endif

struct sockaddr_in recv_addr;
int fd = -1;

if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
throw std::runtime_error("Error creating socket!");
throw satdump_exception("Error creating socket!");

int val_true = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val_true, sizeof(val_true)) < 0)
throw std::runtime_error("Error setting socket option!");
throw satdump_exception("Error setting socket option!");

memset(&recv_addr, 0, sizeof(recv_addr));
recv_addr.sin_family = AF_INET;
recv_addr.sin_port = htons(internal_port);
recv_addr.sin_addr.s_addr = INADDR_ANY;

if (bind(fd, (struct sockaddr *)&recv_addr, sizeof(recv_addr)) < 0)
throw std::runtime_error("Error binding socket!");
throw satdump_exception("Error binding socket!");

uint8_t buffer_rx[65536];

Expand All @@ -56,7 +56,7 @@ namespace bochum
socklen_t response_addr_len = sizeof(response_addr);
int nrecv = recvfrom(fd, (char *)buffer_rx, 65536, 0, (struct sockaddr *)&response_addr, &response_addr_len);
if (nrecv < 0)
throw std::runtime_error("Error on recvfrom!");
throw satdump_exception("Error on recvfrom!");

try
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/dvb_support/dvbs/module_dvbs_demod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace dvb
if (parameters.count("pll_bw") > 0)
d_loop_bw = parameters["pll_bw"].get<float>();
else
throw std::runtime_error("PLL BW parameter must be present!");
throw satdump_exception("PLL BW parameter must be present!");

if (parameters.count("clock_alpha") > 0)
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/dvb_support/dvbs2/module_dvbs2_demod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ namespace dvb
if (parameters.count("rrc_alpha") > 0)
d_rrc_alpha = parameters["rrc_alpha"].get<float>();
else
throw std::runtime_error("RRC Alpha parameter must be present!");
throw satdump_exception("RRC Alpha parameter must be present!");

if (parameters.count("rrc_taps") > 0)
d_rrc_taps = parameters["rrc_taps"].get<int>();

if (parameters.count("pll_bw") > 0)
d_loop_bw = parameters["pll_bw"].get<float>();
else
throw std::runtime_error("PLL BW parameter must be present!");
throw satdump_exception("PLL BW parameter must be present!");

if (parameters.count("freq_prop_factor") > 0)
freq_propagation_factor = parameters["freq_prop_factor"].get<float>();
Expand All @@ -50,7 +50,7 @@ namespace dvb
if (parameters.count("modcod") > 0)
d_modcod = parameters["modcod"].get<int>();
else
throw std::runtime_error("MODCOD parameter must be present!");
throw satdump_exception("MODCOD parameter must be present!");

if (parameters.count("shortframes") > 0)
d_shortframes = parameters["shortframes"].get<bool>();
Expand Down
3 changes: 2 additions & 1 deletion plugins/dvb_support/dvbs2/module_s2_ts_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "imgui/imgui.h"
#include "common/codings/dvb-s2/bbframe_ts_parser.h"
#include "common/utils.h"
#include "core/exception.h"

#if !(defined(__APPLE__) || defined(_WIN32))
#include <netdb.h>
Expand Down Expand Up @@ -35,7 +36,7 @@ namespace dvbs2
if (parameters.count("modcod") > 0)
d_modcod = parameters["modcod"].get<int>();
else
throw std::runtime_error("MODCOD parameter must be present!");
throw satdump_exception("MODCOD parameter must be present!");

if (parameters.count("shortframes") > 0)
d_shortframes = parameters["shortframes"].get<bool>();
Expand Down
3 changes: 2 additions & 1 deletion plugins/eos_support/eos/module_eos_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "common/calibration.h"
#include "instruments/modis/calibrator/modis_calibrator.h"
#include "core/exception.h"

namespace eos
{
Expand All @@ -31,7 +32,7 @@ namespace eos
else if (parameters["satellite"] == "aura")
d_satellite = AURA;
else
throw std::runtime_error("EOS Instruments Decoder : EOS satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
throw satdump_exception("EOS Instruments Decoder : EOS satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
}

void EOSInstrumentsDecoderModule::process()
Expand Down
3 changes: 2 additions & 1 deletion plugins/fengyun3_support/fengyun3/module_fy3_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "instruments/mersi_histmatch.h"
#include "instruments/mersi_offset_interleaved.h"
#include "nlohmann/json_utils.h"
#include "core/exception.h"

namespace fengyun3
{
Expand All @@ -38,7 +39,7 @@ namespace fengyun3
else if (parameters["satellite"] == "fy3g")
d_satellite = FY_3G;
else
throw std::runtime_error("FY3 Instruments Decoder : FY3 satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
throw satdump_exception("FY3 Instruments Decoder : FY3 satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");

if (parameters["downlink"] == "ahrpt")
d_downlink = AHRPT;
Expand Down
5 changes: 3 additions & 2 deletions plugins/inmarsat_support/aero/acars_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "acars_parser.h"
#include "logger.h"
#include <algorithm>
#include "core/exception.h"

namespace inmarsat
{
Expand Down Expand Up @@ -43,7 +44,7 @@ namespace inmarsat
for (int k = 4; k < 11; k++)
{
if (!char_parity[k])
throw std::runtime_error("Acars Text Parity Error");
throw satdump_exception("Acars Text Parity Error");
plane_reg += pkt[k] & 0x7F;
}

Expand All @@ -54,7 +55,7 @@ namespace inmarsat
for (int k = 16; k < (int)pkt.size() - 4; k++)
{
if (!char_parity[k])
throw std::runtime_error("Acars Text Parity Error");
throw satdump_exception("Acars Text Parity Error");
char ch = pkt[k] & 0x7F;
if (ch == 0x7F)
message += "<DEL>";
Expand Down
5 changes: 3 additions & 2 deletions plugins/inmarsat_support/stdc/packets_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <cstdint>
#include <vector>
#include "nlohmann/json.hpp"
#include "core/exception.h"

namespace inmarsat
{
Expand Down Expand Up @@ -113,15 +114,15 @@ namespace inmarsat

// Check length is valid
if (descriptor.length > len_max)
throw std::runtime_error("Invalid PKT length!");
throw satdump_exception("Invalid PKT length!");

// Check CRC
uint16_t sent_crc = (pkt[descriptor.length - 2] << 8) | pkt[descriptor.length - 1];
uint16_t comp_crc = compute_crc(pkt, descriptor.length);
bool crc_valid = sent_crc == 0 || sent_crc == comp_crc;

if (!crc_valid)
throw std::runtime_error("Invalid CRC!");
throw satdump_exception("Invalid CRC!");
}

// NLOHMANN_DEFINE_TYPE_INTRUSIVE(PacketBase, descriptor)
Expand Down
3 changes: 2 additions & 1 deletion plugins/noaa_metop_support/instruments/mhs/mhs_calibrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "products/image_products.h"
#include "nlohmann/json.hpp"
#include "core/exception.h"

class NoaaMHSCalibrator : public satdump::ImageProducts::CalibratorBase
{
Expand All @@ -24,7 +25,7 @@ class NoaaMHSCalibrator : public satdump::ImageProducts::CalibratorBase
void init()
{
if (!d_calib.contains("vars") || !d_calib["vars"].contains("perLine_perChannel"))
throw std::runtime_error("Calibration data missing!");
throw satdump_exception("Calibration data missing!");
perLine_perChannel = d_calib["vars"]["perLine_perChannel"];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace orbcomm
if (input_data_type == DATA_FILE)
{
filesize = file_source->getFilesize();
throw std::runtime_error("The Orbcomm Auto STX Demodulator is live-only!");
throw satdump_exception("The Orbcomm Auto STX Demodulator is live-only!");
}
else
filesize = 0;
Expand Down
3 changes: 2 additions & 1 deletion plugins/proba_support/proba/module_proba_instruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "common/ccsds/ccsds_standard/demuxer.h"
#include "products/products.h"
#include "products/dataset.h"
#include "core/exception.h"

namespace proba
{
Expand All @@ -24,7 +25,7 @@ namespace proba
else if (parameters["satellite"] == "probaV")
d_satellite = PROBA_V;
else
throw std::runtime_error("Proba Instruments Decoder : Proba satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
throw satdump_exception("Proba Instruments Decoder : Proba satellite \"" + parameters["satellite"].get<std::string>() + "\" is not valid!");
}

void PROBAInstrumentsDecoderModule::process()
Expand Down
20 changes: 10 additions & 10 deletions plugins/sdr_sources/aaronia_sdr_support/aaronia_sdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::wstring get_spectran_samplerate_str(uint64_t rate)
else if (rate == SPECTRAN_SAMPLERATE_245M)
return L"245MHz";
else
throw std::runtime_error("Invalid samplerate!");
throw satdump_exception("Invalid samplerate!");
}

std::wstring get_spectran_usbcomp_str(int mode)
Expand All @@ -29,7 +29,7 @@ std::wstring get_spectran_usbcomp_str(int mode)
else if (mode == 2)
return L"compressed";
else
throw std::runtime_error("Invalid USB compression!");
throw satdump_exception("Invalid USB compression!");
}

std::wstring get_spectran_agc_str(int mode)
Expand All @@ -41,7 +41,7 @@ std::wstring get_spectran_agc_str(int mode)
else if (mode == 2)
return L"power";
else
throw std::runtime_error("Invalid AGC mode!");
throw satdump_exception("Invalid AGC mode!");
}

void AaroniaSource::set_gains()
Expand Down Expand Up @@ -147,21 +147,21 @@ void AaroniaSource::start()
AARTSAAPI_Open(&aaronia_handle);

if (AARTSAAPI_RescanDevices(&aaronia_handle, 2000) != AARTSAAPI_OK)
throw std::runtime_error("Could not scan for Aaronia Devices!");
throw satdump_exception("Could not scan for Aaronia Devices!");

// if (AARTSAAPI_EnumDevice(&aaronia_handle, L"spectranv6", 0, &aaronia_dinfo) != AARTSAAPI_OK)
for (uint64_t i = 0; AARTSAAPI_EnumDevice(&aaronia_handle, L"spectranv6", i, &aaronia_dinfo) == AARTSAAPI_OK; i++)
goto got_device;
throw std::runtime_error("Could not enum Aaronia Devices!");
throw satdump_exception("Could not enum Aaronia Devices!");
got_device:

if (AARTSAAPI_OpenDevice(&aaronia_handle, &aaronia_device, L"spectranv6/raw", aaronia_dinfo.serialNumber) != AARTSAAPI_OK)
throw std::runtime_error("Could not open Aaronia Device!");
throw satdump_exception("Could not open Aaronia Device!");

is_started = true;

if (AARTSAAPI_ConfigRoot(&aaronia_device, &root) != AARTSAAPI_OK)
throw std::runtime_error("Could not get Aaronia ConfigRoot!");
throw satdump_exception("Could not get Aaronia ConfigRoot!");

if (AARTSAAPI_ConfigFind(&aaronia_device, &root, &config, L"device/receiverchannel") == AARTSAAPI_OK)
{
Expand Down Expand Up @@ -227,10 +227,10 @@ void AaroniaSource::start()
set_gains();

if (AARTSAAPI_ConnectDevice(&aaronia_device) != AARTSAAPI_OK)
throw std::runtime_error("Could not connect to Aaronia device!");
throw satdump_exception("Could not connect to Aaronia device!");

if (AARTSAAPI_StartDevice(&aaronia_device) != AARTSAAPI_OK)
throw std::runtime_error("Could not start Aaronia device!");
throw satdump_exception("Could not start Aaronia device!");

// Wait
logger->info("Waiting for device to stream...");
Expand Down Expand Up @@ -334,7 +334,7 @@ void AaroniaSource::set_samplerate(uint64_t samplerate)
}
}

throw std::runtime_error("Unspported samplerate : " + std::to_string(samplerate) + "!");
throw satdump_exception("Unspported samplerate : " + std::to_string(samplerate) + "!");
}

uint64_t AaroniaSource::get_samplerate()
Expand Down
6 changes: 3 additions & 3 deletions plugins/sdr_sources/airspy_sdr_support/airspy_sdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ void AirspySource::open_sdr()
{
#ifndef __ANDROID__
if (airspy_open_sn(&airspy_dev_obj, d_sdr_id) != AIRSPY_SUCCESS)
throw std::runtime_error("Could not open Airspy device!");
throw satdump_exception("Could not open Airspy device!");
#else
int vid, pid;
std::string path;
int fd = getDeviceFD(vid, pid, AIRSPY_USB_VID_PID, path);
if (airspy_open_fd(&airspy_dev_obj, fd) != AIRSPY_SUCCESS)
throw std::runtime_error("Could not open Airspy device!");
throw satdump_exception("Could not open Airspy device!");
#endif
}

Expand Down Expand Up @@ -240,7 +240,7 @@ void AirspySource::drawControlUI()
void AirspySource::set_samplerate(uint64_t samplerate)
{
if (!samplerate_widget.set_value(samplerate, 10e6))
throw std::runtime_error("Unspported samplerate : " + std::to_string(samplerate) + "!");
throw satdump_exception("Unspported samplerate : " + std::to_string(samplerate) + "!");
}

uint64_t AirspySource::get_samplerate()
Expand Down
6 changes: 3 additions & 3 deletions plugins/sdr_sources/airspyhf_sdr_support/airspyhf_sdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ void AirspyHFSource::open_sdr()
{
#ifndef __ANDROID__
if (airspyhf_open_sn(&airspyhf_dev_obj, d_sdr_id) != AIRSPYHF_SUCCESS)
throw std::runtime_error("Could not open AirspyHF device!");
throw satdump_exception("Could not open AirspyHF device!");
#else
int vid, pid;
std::string path;
int fd = getDeviceFD(vid, pid, AIRSPYHF_USB_VID_PID, path);
if (airspyhf_open_fd(&airspyhf_dev_obj, fd) != AIRSPYHF_SUCCESS)
throw std::runtime_error("Could not open AirspyHF device!");
throw satdump_exception("Could not open AirspyHF device!");
#endif
}

Expand Down Expand Up @@ -173,7 +173,7 @@ void AirspyHFSource::drawControlUI()
void AirspyHFSource::set_samplerate(uint64_t samplerate)
{
if (!samplerate_widget.set_value(samplerate, 3.2e6))
throw std::runtime_error("Unspported samplerate : " + std::to_string(samplerate) + "!");
throw satdump_exception("Unspported samplerate : " + std::to_string(samplerate) + "!");
}

uint64_t AirspyHFSource::get_samplerate()
Expand Down
Loading

0 comments on commit 7c0e2dc

Please sign in to comment.