mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 01:45:38 +08:00
refs #815 Added convertFromJsonNoThrow methods which catch CJsonException and return CStatusMessage.
This commit is contained in:
@@ -336,8 +336,37 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
// CContainerBase methods implemented out-of-line to avoid circular include
|
||||
template <template <class> class C, class T, class CIt>
|
||||
CStatusMessage CContainerBase<C, T, CIt>::convertFromJsonNoThrow(const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
|
||||
{
|
||||
try
|
||||
{
|
||||
convertFromJson(json);
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
return ex.toStatusMessage(categories, prefix);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
//! Call convertFromJson, catch any CJsonException that is thrown and return it as CStatusMessage.
|
||||
template <template <class> class C, class T, class CIt>
|
||||
CStatusMessage CContainerBase<C, T, CIt>::convertFromJsonNoThrow(const QString &jsonString, const CLogCategoryList &categories, const QString &prefix)
|
||||
{
|
||||
try
|
||||
{
|
||||
convertFromJson(jsonString);
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
return ex.toStatusMessage(categories, prefix);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::CStatusMessage)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CStatusMessage::StatusSeverity)
|
||||
|
||||
Reference in New Issue
Block a user