1
0
Fork 0

Sentry: add ‘updateTag’ helper to modify tags

Use this to fix reported tags in a few erroneous places.
This commit is contained in:
James Turner 2021-06-26 16:25:14 +01:00
parent c872af41bf
commit 8e90e4657f
4 changed files with 26 additions and 5 deletions

View file

@ -58,8 +58,8 @@ void XMLLoader::load(FGGroundNetwork* net)
FGGroundNetXMLLoader visitor(net);
readXML(path, visitor);
if (visitor.hasErrors()) {
flightgear::addSentryTag("ground-net", net->airport()->ident());
if (visitor.hasErrors() && fgGetBool("/sim/terrasync/enabled")) {
flightgear::updateSentryTag("ground-net", net->airport()->ident());
flightgear::sentryReportException("Ground-net load error", path.utf8Str());
}
} catch (sg_exception& e) {
@ -90,8 +90,9 @@ void XMLLoader::loadFromPath(FGGroundNetwork* net, const SGPath& path)
flightgear::SentryXMLErrorSupression xs;
FGGroundNetXMLLoader visitor(net);
readXML(path, visitor);
if (visitor.hasErrors()) {
flightgear::addSentryTag("ground-net", net->airport()->ident());
if (visitor.hasErrors() && fgGetBool("/sim/terrasync/enabled")) {
flightgear::updateSentryTag("ground-net", net->airport()->ident());
flightgear::sentryReportException("Ground-net load error", path.utf8Str());
}
} catch (sg_exception& e) {

View file

@ -1202,7 +1202,7 @@ void fgStartReposition()
void fgStartNewReset()
{
flightgear::addSentryTag("have-reset", "yes");
flightgear::updateSentryTag("have-reset", "yes");
// save user settings now, so that USERARCIVE-d values changes since the
// last init are recorded and hence re-loaded when we fgInitConfig down

View file

@ -403,6 +403,18 @@ void addSentryTag(const char* tag, const char* value)
sentry_set_tag(tag, value);
}
void updateSentryTag(const std::string& tag, const std::string& value)
{
if (tag.empty() || value.empty())
return;
if (!static_sentryEnabled)
return;
sentry_remove_tag(tag.c_str());
sentry_set_tag(tag.c_str(), value.c_str());
}
void sentryReportNasalError(const std::string& msg, const string_list& stack)
{
if (!static_sentryEnabled)
@ -538,6 +550,11 @@ void addSentryTag(const char*, const char*)
{
}
void updateSentryTag(const std::string&, const std::string&)
{
}
void sentryReportNasalError(const std::string&, const string_list&)
{
}

View file

@ -37,6 +37,9 @@ void addSentryTag(const char* tag, const char* value);
void addSentryTag(const std::string& tag, const std::string& value);
void updateSentryTag(const std::string& tag, const std::string& value);
void sentryReportNasalError(const std::string& msg, const string_list& stack);
void sentryReportException(const std::string& msg, const std::string& location = {});