-
Notifications
You must be signed in to change notification settings - Fork 327
Handle exceptions instead of crash #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
af7e365
64a8755
f7e260a
eb6156b
bc00e13
1ac2bc7
b8e5d0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,7 @@ | |
| #include <QGuiApplication> | ||
| #include <QJsonObject> | ||
| #include <QKeyEvent> | ||
| #include <QLatin1String> | ||
| #include <QLineEdit> | ||
| #include <QList> | ||
| #include <QLocale> | ||
|
|
@@ -54,6 +55,7 @@ | |
| #include <QShortcut> | ||
| #include <QSize> | ||
| #include <QString> | ||
| #include <QStringBuilder> | ||
| #include <QTextDocument> // for Qt::mightBeRichText | ||
| #include <QThread> | ||
| #include <QUrlQuery> | ||
|
|
@@ -893,4 +895,22 @@ QImage GetImage(const QLabel* label) | |
| #endif | ||
| } | ||
|
|
||
| QString MakeHtmlLink(const QString& source, const QString& link) | ||
| { | ||
| return QString(source).replace( | ||
| link, | ||
| QLatin1String("<a href=\"") % link % QLatin1String("\">") % link % QLatin1String("</a>")); | ||
| } | ||
|
|
||
| void PrintSlotException( | ||
| const std::exception* exception, | ||
| const QObject* sender, | ||
| const QObject* receiver) | ||
| { | ||
| std::string description = sender->metaObject()->className(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In commit "qt: Add GUIUtil::ExceptionSafeConnect function" (f7e260a) Not important, but just in case you revisit this, I think it might be a little clearer to call this variable "location" instead of "description". (I was a little confused at first about why it didn't seem to include information from the exception.) |
||
| description += "->"; | ||
| description += receiver->metaObject()->className(); | ||
| PrintExceptionContinue(exception, description.c_str()); | ||
| } | ||
|
|
||
| } // namespace GUIUtil | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,10 @@ WalletModel::~WalletModel() | |
| void WalletModel::startPollBalance() | ||
| { | ||
| // This timer will be fired repeatedly to update the balance | ||
| connect(timer, &QTimer::timeout, this, &WalletModel::pollBalanceChanged); | ||
| // Since the QTimer::timeout is a private signal, it cannot be used | ||
| // in the GUIUtil::ExceptionSafeConnect directly. | ||
| connect(timer, &QTimer::timeout, this, &WalletModel::timerTimeout); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want to add a comment here why the signal is not directly connected (e.g. because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Updated. |
||
| GUIUtil::ExceptionSafeConnect(this, &WalletModel::timerTimeout, this, &WalletModel::pollBalanceChanged); | ||
| timer->start(MODEL_UPDATE_DELAY); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "qt: Make PACKAGE_BUGREPORT link clickable" (af7e365)
Since our project only uses the issue tracker for development, not user support, it would be good in the future to link to something like stack exchange or a support resources page if a fatal error occurs, instead of the issue tracker.
But this commit is only making existing issue tracker links clickable, not adding new links, so it doesn't cause problems and is good because it keeps the links rendered in consistent way.
In the future it might be be good stop having "Runaway exception" dialogs and instead have distinct "Internal bug" (e.g. unhandled preconditions or postconditions) and "Fatal error" (e.g. failing disk writes) dialogs, treating the first kind like bugs and the second kind like support issues. But it seems good to keep the scope of this PR narrow and focused on the nonfatal checks like it is now.