mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-29 05:24:18 -04:00
e86e95feab
The original leansdr code uses fatal() and fail() for unrecoverable errors by terminating execution. When integrated into SDRangel, these error paths did not provide a mechanism for the plugin to handle failures locally, allowing initialization failures to escape the normal plugin lifecycle. Convert leansdr fatal() and fail() handling into C++ exceptions so DATV can detect framework initialization failures, report them, and cleanly return control to SDRangel instead of allowing the error to terminate the application. This behavior is desirable because a DATV framework configuration failure should not bring down the entire application. Catch initialization exceptions in DATVDemodSink::feed(), report the failure, clean up the partially initialized framework, and return to the caller. Add noreturn annotations to the leansdr error functions and include the leansdr source in exception messages to make failures easier to diagnose. This does not redesign leansdr error handling or provide recovery from runtime DSP failures. It only adds an exception boundary between the leansdr library code and the SDRangel plugin lifecycle. noticed via cppcheck indicating many Array indexes could go out of bounds due to fail and fatal returning. Signed-off-by: Robin Getz <rgetz503@gmail.com>
37 lines
1.7 KiB
C++
37 lines
1.7 KiB
C++
///////////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (C) 2019, 2021 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
// //
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU General Public License V3 for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
#include "framework.h"
|
|
|
|
namespace leansdr
|
|
{
|
|
|
|
[[noreturn]] void fatal(const char *s) {
|
|
perror(s);
|
|
throw std::runtime_error(std::string("leansdr fatal: ") + s);
|
|
}
|
|
|
|
[[noreturn]] void fail(const char *s) {
|
|
fprintf(stderr, "** leansdr fail: %s\n", s);
|
|
throw std::runtime_error(std::string("leansdr fail: ") + s);
|
|
}
|
|
|
|
} // leansdr
|