forked from Silverfish/proton-bridge
feat(GODT-2446): Attach logs to sentry reports for relevant bridge-gui exceptions.
Cherry picked from release/perth_narrows (2aa4e7c)
# Conflicts:
# internal/frontend/bridge-gui/bridge-gui/AppController.cpp
# internal/frontend/bridge-gui/bridge-gui/AppController.h
# internal/frontend/bridge-gui/bridge-gui/LogUtils.cpp
# internal/frontend/bridge-gui/bridge-gui/LogUtils.h
# internal/frontend/bridge-gui/bridge-gui/QMLBackend.cpp
# internal/frontend/bridge-gui/bridge-gui/SentryUtils.cpp
# internal/frontend/bridge-gui/bridge-gui/SentryUtils.h
# internal/frontend/bridge-gui/bridge-gui/main.cpp
This commit is contained in:
@ -25,12 +25,15 @@ namespace bridgepp {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] what A description of the exception.
|
||||
/// \param[in] details The optional details for the exception.
|
||||
/// \param[in] function The name of the calling function.
|
||||
//****************************************************************************************************************************************************
|
||||
Exception::Exception(QString qwhat, QString details) noexcept
|
||||
Exception::Exception(QString qwhat, QString details, QString function, QByteArray attachment) noexcept
|
||||
: std::exception()
|
||||
, qwhat_(std::move(qwhat))
|
||||
, what_(qwhat_.toLocal8Bit())
|
||||
, details_(std::move(details)) {
|
||||
, details_(std::move(details))
|
||||
, function_(std::move(function))
|
||||
, attachment_(std::move(attachment)) {
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +44,9 @@ Exception::Exception(Exception const &ref) noexcept
|
||||
: std::exception(ref)
|
||||
, qwhat_(ref.qwhat_)
|
||||
, what_(ref.what_)
|
||||
, details_(ref.details_) {
|
||||
, details_(ref.details_)
|
||||
, function_(ref.function_)
|
||||
, attachment_(ref.attachment_) {
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +57,9 @@ Exception::Exception(Exception &&ref) noexcept
|
||||
: std::exception(ref)
|
||||
, qwhat_(ref.qwhat_)
|
||||
, what_(ref.what_)
|
||||
, details_(ref.details_) {
|
||||
, details_(ref.details_)
|
||||
, function_(ref.function_)
|
||||
, attachment_(ref.attachment_) {
|
||||
}
|
||||
|
||||
|
||||
@ -80,4 +87,26 @@ QString Exception::details() const noexcept {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The attachment for the exception.
|
||||
//****************************************************************************************************************************************************
|
||||
QByteArray Exception::attachment() const noexcept {
|
||||
return attachment_;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The details exception.
|
||||
//****************************************************************************************************************************************************
|
||||
QString Exception::detailedWhat() const {
|
||||
QString result = qwhat_;
|
||||
if (!function_.isEmpty()) {
|
||||
result = QString("%1(): %2").arg(function_, result);
|
||||
}
|
||||
if (!details_.isEmpty()) {
|
||||
result += "\n\nDetails:\n" + details_;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace bridgepp
|
||||
|
||||
@ -31,7 +31,8 @@ namespace bridgepp {
|
||||
//****************************************************************************************************************************************************
|
||||
class Exception : public std::exception {
|
||||
public: // member functions
|
||||
explicit Exception(QString qwhat = QString(), QString details = QString()) noexcept; ///< Constructor
|
||||
explicit Exception(QString qwhat = QString(), QString details = QString(), QString function = QString(),
|
||||
QByteArray attachment = QByteArray()) noexcept; ///< Constructor
|
||||
Exception(Exception const &ref) noexcept; ///< copy constructor
|
||||
Exception(Exception &&ref) noexcept; ///< copy constructor
|
||||
Exception &operator=(Exception const &) = delete; ///< Disabled assignment operator
|
||||
@ -40,11 +41,15 @@ public: // member functions
|
||||
QString qwhat() const noexcept; ///< Return the description of the exception as a QString
|
||||
const char *what() const noexcept override; ///< Return the description of the exception as C style string
|
||||
QString details() const noexcept; ///< Return the details for the exception
|
||||
QByteArray attachment() const noexcept; ///< Return the attachment for the exception.
|
||||
QString detailedWhat() const; ///< Return the detailed description of the message (i.e. including the function name and the details).
|
||||
|
||||
private: // data members
|
||||
QString const qwhat_; ///< The description of the exception.
|
||||
QByteArray const what_; ///< The c-string version of the qwhat message. Stored as a QByteArray for automatic lifetime management.
|
||||
QString const details_; ///< The optional details for the exception.
|
||||
QString const function_; ///< The name of the function that created the exception.
|
||||
QByteArray const attachment_; ///< The attachment to add to the exception.
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user