Skip to content

wizard: raise more specific exc in create_storage() and pass some to crash reporter#10121

Merged
SomberNight merged 4 commits intospesmilo:masterfrom
f321x:qml_create_storage_exc
Feb 10, 2026
Merged

wizard: raise more specific exc in create_storage() and pass some to crash reporter#10121
SomberNight merged 4 commits intospesmilo:masterfrom
f321x:qml_create_storage_exc

Conversation

@f321x
Copy link
Copy Markdown
Member

@f321x f321x commented Aug 12, 2025

Currently the exceptions raised by create_storage() are all plain Exception and shown as warning in the GUI. This causes us to miss bugs like #10117 because they never get forwarded to the crash reporter.

This PR makes the exception types of create_storage() more specific, UserFacingException are still shown to the user as before, but other exception types are caught in the calling GUI and forwarded to the crash reporter instead.

@f321x f321x added the topic-wizard 🧙‍♂️ related to wallet creation/restore wizard label Aug 12, 2025
@f321x f321x force-pushed the qml_create_storage_exc branch from 33eb847 to f92e9e5 Compare August 12, 2025 09:01
@f321x f321x force-pushed the qml_create_storage_exc branch from f92e9e5 to 9f0d9c5 Compare February 4, 2026 10:35
f321x added a commit to f321x/electrum-fork that referenced this pull request Feb 4, 2026
I tried to reproduce:
spesmilo#8815 (comment)
which triggered the following exception for me:

```
Traceback (most recent call last):
  File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 409, in start_new_window
    window = self._create_window_for_wallet(wallet)
  File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 329, in _create_window_for_wallet
    w = ElectrumWindow(self, wallet)
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 290, in __init__
    self.load_wallet(wallet)
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/user/code/electrum-fork/electrum/util.py", line 495, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 589, in load_wallet
    self.update_recently_opened_menu()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 741, in update_recently_opened_menu
    for i, k in enumerate(recent):
                ~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not iterable
```

This happens because the trustedcoin wallet is loaded outside of
Daemon.load_wallet() so Daemon.update_recently_opened_wallets()
is not getting called and config.RECENTLY:_OPEN_WALLET_FILES is
still None when we try to iterate through it.
As fix i now call update_recently_opened_wallets directy in
Daemon.add_wallet() and additionally handle
RECENTLY_OPEN_WALLET_FILES being None in
ElectrumWindow.update_recently_opened_menu().

My pull request spesmilo#10121
would have sent this exception to the crash reporter so we
might have noticed it earlier. I think we should not just catch
all exceptions in the wizard like on master as it causes us to
repeatedly miss regressions in the wizard that could be sent to
the crash reporter.
f321x added 3 commits February 4, 2026 11:56
Modifies `NewWalletWizard.create_storage()` to raise more specific
exception types instead of plain `Exception`. This should allow the
calling GUI to separate between non-bug exceptions (like invalid user
input), and bugs which should not happen and be
passed to the bug reporter.
Differentiate between the `UserFacingException` and other exceptions
when creating the storage. Forward other exceptions to the reporter so
they can get fixed.
Differentiate between the `UserFacingException` and other exceptions
when creating the storage. Forward other exceptions to the reporter so
they can get fixed.
@f321x f321x force-pushed the qml_create_storage_exc branch from 9f0d9c5 to 2fd74c1 Compare February 4, 2026 10:57
Copy link
Copy Markdown
Member

@SomberNight SomberNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I agree with the concept, we should distinguish bugs vs expected exceptions.

Comment thread electrum/gui/qt/__init__.py Outdated
Comment on lines 421 to 423
elif isinstance(e, WalletFileException) and e.should_report_crash \
or not isinstance(e, WalletFileException):
send_exception_to_crash_reporter(e)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif isinstance(e, WalletFileException) and e.should_report_crash \
or not isinstance(e, WalletFileException):
send_exception_to_crash_reporter(e)
else:
send_exception_to_crash_reporter(e)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in followup.

@SomberNight SomberNight merged commit f2a7035 into spesmilo:master Feb 10, 2026
3 of 16 checks passed
f321x added a commit to f321x/electrum-fork that referenced this pull request Feb 11, 2026
I tried to reproduce:
spesmilo#8815 (comment)
which triggered the following exception for me:

```
Traceback (most recent call last):
  File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 409, in start_new_window
    window = self._create_window_for_wallet(wallet)
  File "/home/user/code/electrum-fork/electrum/gui/qt/__init__.py", line 329, in _create_window_for_wallet
    w = ElectrumWindow(self, wallet)
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 290, in __init__
    self.load_wallet(wallet)
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/user/code/electrum-fork/electrum/util.py", line 495, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 589, in load_wallet
    self.update_recently_opened_menu()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/user/code/electrum-fork/electrum/gui/qt/main_window.py", line 741, in update_recently_opened_menu
    for i, k in enumerate(recent):
                ~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not iterable
```

This happens because the trustedcoin wallet is loaded outside of
Daemon.load_wallet() so Daemon.update_recently_opened_wallets()
is not getting called and config.RECENTLY:_OPEN_WALLET_FILES is
still None when we try to iterate through it.
As fix i now use load_wallet() instead of manually
instantiating the Wallet
and additionally handle
RECENTLY_OPEN_WALLET_FILES being None in
ElectrumWindow.update_recently_opened_menu().

My pull request spesmilo#10121
would have sent this exception to the crash reporter so we
might have noticed it earlier. I think we should not just catch
all exceptions in the wizard like on master as it causes us to
repeatedly miss regressions in the wizard that could be sent to
the crash reporter.
@f321x f321x deleted the qml_create_storage_exc branch February 11, 2026 08:20
SomberNight added a commit that referenced this pull request Feb 26, 2026
wizard: raise more specific exc in create_storage() and pass some to crash reporter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-wizard 🧙‍♂️ related to wallet creation/restore wizard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants