Add exception check in toURI() call

Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
Loren Eteval
2024-03-07 13:29:12 +08:00
parent 3976d1a699
commit 7fab169a86
2 changed files with 17 additions and 2 deletions
+11 -1
View File
@@ -1201,9 +1201,19 @@ class UserServersQTableWidget(QTranslatable, AppQTableWidget):
# Nothing selected. Do nothing
return
def toURI(factory) -> str:
assert isinstance(factory, ConfigurationFactory)
try:
return factory.toURI()
except Exception:
# Any non-exit exceptions
return ''
# TODO: MessageBox?
QApplication.clipboard().setText(
'\n'.join(list(AS_UserServers()[index].toURI() for index in indexes))
'\n'.join(list(toURI(AS_UserServers()[index]) for index in indexes))
)
def exportSelectedItemQR(self):
+6 -1
View File
@@ -57,7 +57,12 @@ class QRCodeWindow(SupportImplicitReference, AppQMainWindow):
config = AS_UserServers()[index]
uri = config.toURI()
try:
uri = config.toURI()
except Exception:
# Any non-exit exceptions
uri = ''
if uri:
qrcode = pyqrcode.create(uri)