kopia lustrzana https://github.com/ukhas/habitat-cpp-connector
Make not initialised its own error to help dl-fldigi
rodzic
a1d56d58cd
commit
b641981709
|
@ -9,7 +9,7 @@ namespace habitat {
|
||||||
void UploaderAction::check(habitat::Uploader *u)
|
void UploaderAction::check(habitat::Uploader *u)
|
||||||
{
|
{
|
||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
throw runtime_error("Uploader settings were not initialised");
|
throw NotInitialisedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploaderSettings::apply(UploaderThread &uthr)
|
void UploaderSettings::apply(UploaderThread &uthr)
|
||||||
|
@ -224,6 +224,11 @@ void *UploaderThread::run()
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
catch (NotInitialisedError &e)
|
||||||
|
{
|
||||||
|
caught_exception(e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
catch (runtime_error &e)
|
catch (runtime_error &e)
|
||||||
{
|
{
|
||||||
caught_exception(e);
|
caught_exception(e);
|
||||||
|
@ -261,6 +266,12 @@ void UploaderThread::reset_done()
|
||||||
log("Settings reset");
|
log("Settings reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UploaderThread::caught_exception(const NotInitialisedError &error)
|
||||||
|
{
|
||||||
|
const string what(error.what());
|
||||||
|
warning("Caught NotInitialisedError");
|
||||||
|
}
|
||||||
|
|
||||||
void UploaderThread::caught_exception(const runtime_error &error)
|
void UploaderThread::caught_exception(const runtime_error &error)
|
||||||
{
|
{
|
||||||
const string what(error.what());
|
const string what(error.what());
|
||||||
|
|
|
@ -13,6 +13,12 @@ using namespace std;
|
||||||
/* Add some more EZ stuff. */
|
/* Add some more EZ stuff. */
|
||||||
namespace habitat {
|
namespace habitat {
|
||||||
|
|
||||||
|
class NotInitialisedError : public runtime_error
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NotInitialisedError() : runtime_error("habitat::NotInitialisedError") {};
|
||||||
|
};
|
||||||
|
|
||||||
class UploaderThread;
|
class UploaderThread;
|
||||||
|
|
||||||
class UploaderAction
|
class UploaderAction
|
||||||
|
@ -187,6 +193,7 @@ public:
|
||||||
virtual void saved_id(const string &type, const string &id);
|
virtual void saved_id(const string &type, const string &id);
|
||||||
virtual void initialised();
|
virtual void initialised();
|
||||||
virtual void reset_done();
|
virtual void reset_done();
|
||||||
|
virtual void caught_exception(const NotInitialisedError &error);
|
||||||
virtual void caught_exception(const runtime_error &error);
|
virtual void caught_exception(const runtime_error &error);
|
||||||
virtual void caught_exception(const invalid_argument &error);
|
virtual void caught_exception(const invalid_argument &error);
|
||||||
virtual void got_flights(const vector<Json::Value> &flights);
|
virtual void got_flights(const vector<Json::Value> &flights);
|
||||||
|
|
|
@ -916,7 +916,7 @@ class TestCPPConnectorThreaded(TestCPPConnector):
|
||||||
try:
|
try:
|
||||||
self.uploader.payload_telemetry("asdf", {})
|
self.uploader.payload_telemetry("asdf", {})
|
||||||
except ProxyException as e:
|
except ProxyException as e:
|
||||||
assert "not initialised" in str(e)
|
assert "NotInitialised" in str(e)
|
||||||
else:
|
else:
|
||||||
raise AssertionError("not initialised was not thrown")
|
raise AssertionError("not initialised was not thrown")
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ class TestUploaderThread : public habitat::UploaderThread
|
||||||
|
|
||||||
void reset_done() { report_result("return"); };
|
void reset_done() { report_result("return"); };
|
||||||
|
|
||||||
|
void caught_exception(const habitat::NotInitialisedError &error)
|
||||||
|
{ report_result("error", "NotInitialisedError"); }
|
||||||
|
|
||||||
void caught_exception(const runtime_error &error)
|
void caught_exception(const runtime_error &error)
|
||||||
{ report_result("error", "runtime_error", error.what()); }
|
{ report_result("error", "runtime_error", error.what()); }
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue