From 792266ea0edfada62642d720c6bddb523de791a5 Mon Sep 17 00:00:00 2001
From: Induwara Jayaweera <62927268+Dev-I-J@users.noreply.github.com>
Date: Thu, 17 Dec 2020 18:50:12 +0530
Subject: [PATCH] v1.6.11 - Improve Fatal Error Dialog [build]
---
.debug/jnote.py | 30 +++++++++++++++---------------
README.md | 2 +-
data/about.html | 2 +-
fileio.py | 20 ++++++++++----------
jnote.py | 30 +++++++++++++++---------------
main.qml | 8 ++++++--
settings.py | 16 ++++++++--------
settings.toml | 2 +-
signals.py | 2 +-
vars.iss | 2 +-
10 files changed, 59 insertions(+), 55 deletions(-)
diff --git a/.debug/jnote.py b/.debug/jnote.py
index 70b1452..77afa85 100644
--- a/.debug/jnote.py
+++ b/.debug/jnote.py
@@ -34,7 +34,7 @@ def checkUpdates(self, isStartup: bool) -> None:
"https://api.github.com/repos/Dev-I-J/JNote/releases/latest"
)
with get(url) as r:
- currentVersionStr: str = "v1.6.9"
+ currentVersionStr: str = "v1.6.11"
currentVersion: Version = Version(currentVersionStr)
newVersionStr: str = r.json()['tag_name']
newVersion: Version = Version(newVersionStr)
@@ -58,8 +58,8 @@ def checkUpdates(self, isStartup: bool) -> None:
self.apiConnectError.emit()
except KeyError:
self.apiError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
finally:
sys.exit()
@@ -88,8 +88,8 @@ def findText(
return result
except re.error as e:
self.regexError.emit(pattern, e.msg)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return []
@pyqtSlot(bool, str)
@@ -100,8 +100,8 @@ def render(self, md: bool, source: str) -> None:
with open(name, "w") as tmpFile:
tmpFile.write(source if not md else markdown(source))
webbrowser.open_new_tab(name)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str)
def shellExec(self, script: str) -> None:
@@ -120,8 +120,8 @@ def shellExec(self, script: str) -> None:
subprocess.run(f"open -W -a Terminal.app {name}")
else:
self.platformNotSupported.emit(sys.platform)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot()
def clean(self) -> None:
@@ -135,8 +135,8 @@ def clean(self) -> None:
pass
except Exception:
self.fatalError.emit(traceback.format_exc())
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@staticmethod
def __addComments() -> None:
@@ -163,8 +163,8 @@ def about(self) -> str:
except FileNotFoundError:
self.readmeFileNotFound.emit()
return "data/about.html Not Found."
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
@pyqtProperty(str, constant=True)
@@ -177,8 +177,8 @@ def gplLicense(self) -> str:
except FileNotFoundError:
self.licenseFileNotFound.emit()
return "data/license.html Not Found."
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
@pyqtProperty("QVariant", constant=True)
diff --git a/README.md b/README.md
index b612385..d251191 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ __JNote is a free NotePad__ application written in _Python and QML (PyQt5)._ Bin
## Features
-The current version is v1.6.10 and additional for basic functions of a note pad, it can
+The current version is v1.6.11 and additional for basic functions of a note pad, it can
* Automatically Check For Updates,
* Determine A File Is Binary Or Not And Show Message,
diff --git a/data/about.html b/data/about.html
index f4be364..9db407c 100644
--- a/data/about.html
+++ b/data/about.html
@@ -6,7 +6,7 @@
JNote - A Free NotePad
JNote is a free NotePad application written in Python and QML (PyQt5). Binaries are available for Windows and Mac, but you can build from source for Linux (See Below).
Features
-The current version is v1.6.10 and additional for basic functions of a note pad, it can
+The current version is v1.6.11 and additional for basic functions of a note pad, it can
- Automatically Check For Updates,
- Determine A File Is Binary Or Not And Show Message,
diff --git a/fileio.py b/fileio.py
index dafb6a2..ce1ba9e 100644
--- a/fileio.py
+++ b/fileio.py
@@ -22,8 +22,8 @@ def fileNew(self) -> None:
self.setSettingsStr("last-used-file", "path", "")
self.setSettingsStr("last-used-file", "text", "")
self.newDocumentCreated.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@ pyqtSlot(str, result=str)
def fileOpen(self, fPath: str) -> str:
@@ -63,8 +63,8 @@ def fileOpen(self, fPath: str) -> str:
self.fileNotFound.emit(fPath)
except IOError:
self.fileHandleError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
@ pyqtSlot(str)
@@ -84,8 +84,8 @@ def fileSave(self, fText: str) -> None:
self.fileNotFound.emit(fPath)
except IOError:
self.fileHandleError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@ pyqtSlot(str, str)
def fileSaveAs(self, fPath: str, fText: str) -> None:
@@ -99,8 +99,8 @@ def fileSaveAs(self, fPath: str, fText: str) -> None:
self.fileNotFound.emit(fPath)
except IOError:
self.fileHandleError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
else:
self.setSettingsBool("last-used-file", "untitled", False)
self.setSettingsStr("last-used-file", "path", fPath)
@@ -119,6 +119,6 @@ def openLastOpenFile(self) -> str:
self.fileOpenError.emit()
except IOError:
self.fileHandleError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
diff --git a/jnote.py b/jnote.py
index 4c65f08..d9f4643 100644
--- a/jnote.py
+++ b/jnote.py
@@ -34,7 +34,7 @@ def checkUpdates(self, isStartup: bool) -> None:
"https://api.github.com/repos/Dev-I-J/JNote/releases/latest"
)
with get(url) as r:
- currentVersionStr: str = "v1.6.10"
+ currentVersionStr: str = "v1.6.11"
currentVersion: Version = Version(currentVersionStr)
newVersionStr: str = r.json()['tag_name']
newVersion: Version = Version(newVersionStr)
@@ -58,8 +58,8 @@ def checkUpdates(self, isStartup: bool) -> None:
self.apiConnectError.emit()
except KeyError:
self.apiError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str, str, bool, bool, result=list)
def findText(
@@ -86,8 +86,8 @@ def findText(
return result
except re.error as e:
self.regexError.emit(pattern, e.msg)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return []
@pyqtSlot(bool, str)
@@ -98,8 +98,8 @@ def render(self, md: bool, source: str) -> None:
with open(name, "w") as tmpFile:
tmpFile.write(source if not md else markdown(source))
webbrowser.open_new_tab(name)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str)
def shellExec(self, script: str) -> None:
@@ -118,8 +118,8 @@ def shellExec(self, script: str) -> None:
subprocess.run(f"open -W -a Terminal.app {name}")
else:
self.platformNotSupported.emit(sys.platform)
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot()
def clean(self) -> None:
@@ -133,8 +133,8 @@ def clean(self) -> None:
pass
except Exception:
self.fatalError.emit(traceback.format_exc())
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@staticmethod
def __addComments() -> None:
@@ -161,8 +161,8 @@ def about(self) -> str:
except FileNotFoundError:
self.readmeFileNotFound.emit()
return "data/about.html Not Found."
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
@pyqtProperty(str, constant=True)
@@ -175,8 +175,8 @@ def gplLicense(self) -> str:
except FileNotFoundError:
self.licenseFileNotFound.emit()
return "data/license.html Not Found."
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return ""
@pyqtProperty("QVariant", constant=True)
diff --git a/main.qml b/main.qml
index 280c168..c3cf8a5 100644
--- a/main.qml
+++ b/main.qml
@@ -766,8 +766,10 @@ ApplicationWindow {
MessageDialog {
id: fatalError
property string error: ""
+ property string shortError: ""
title: "Fatal Error"
- text: "A Fatal Error Occurred!"
+ text: "The Following Fatal Error Had Occurred:"
+ informativeText: shortError
detailedText: error
icon: StandardIcon.Critical
onAccepted: Qt.quit()
@@ -1048,9 +1050,10 @@ ApplicationWindow {
statusText.text = "An Error Occurred with the GitHub API"
}
- function onFatalError(error) {
+ function onFatalError(shortError, error) {
statusText.text = "A Fatal Error Occurred!"
fatalError.error = error
+ fatalError.shortError = shortError
fatalError.open()
}
@@ -1128,6 +1131,7 @@ ApplicationWindow {
}
function onRegexError(regex, error) {
+ statusText.text = "Invalid Regular Expression - \"" + regex + "\"!"
regexError.regex = regex
regexError.error = error
regexError.open()
diff --git a/settings.py b/settings.py
index 355c30f..2a1fd07 100644
--- a/settings.py
+++ b/settings.py
@@ -27,8 +27,8 @@ def setSettingsStr(self, category: str, key: str, value: str) -> None:
self.settingsFileNotFound.emit()
except toml.TomlDecodeError:
self.settingsError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str, str, int)
def setSettingsInt(self, category: str, key: str, value: int) -> None:
@@ -43,8 +43,8 @@ def setSettingsInt(self, category: str, key: str, value: int) -> None:
self.settingsFileNotFound.emit()
except toml.TomlDecodeError:
self.settingsError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str, str, bool)
def setSettingsBool(self, category: str, key: str, value: bool) -> None:
@@ -59,8 +59,8 @@ def setSettingsBool(self, category: str, key: str, value: bool) -> None:
self.settingsFileNotFound.emit()
except toml.TomlDecodeError:
self.settingsError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
@pyqtSlot(str, result='QVariant')
def getSettings(self, category: str) -> Dict[str, Any]:
@@ -73,6 +73,6 @@ def getSettings(self, category: str) -> Dict[str, Any]:
self.settingsFileNotFound.emit()
except toml.TomlDecodeError:
self.settingsError.emit()
- except Exception:
- self.fatalError.emit(traceback.format_exc())
+ except Exception as e:
+ self.fatalError.emit(str(e), traceback.format_exc())
return {}
diff --git a/settings.toml b/settings.toml
index c72ad95..d9eb330 100644
--- a/settings.toml
+++ b/settings.toml
@@ -20,5 +20,5 @@ italic = false
[last-used-file]
untitled = true
path = ""
-text = ""
+text = "["
encoding = "utf-8"
diff --git a/signals.py b/signals.py
index 275c5d2..c674b82 100644
--- a/signals.py
+++ b/signals.py
@@ -14,6 +14,7 @@ def __init__(self) -> None:
readmeFileNotFound: pyqtSignal = pyqtSignal()
fileOpenSuccessful: pyqtSignal = pyqtSignal()
newDocumentCreated: pyqtSignal = pyqtSignal()
+ fatalError: pyqtSignal = pyqtSignal(str, str)
regexError: pyqtSignal = pyqtSignal(str, str)
dateTimeInserted: pyqtSignal = pyqtSignal()
fileHandleError: pyqtSignal = pyqtSignal()
@@ -22,7 +23,6 @@ def __init__(self) -> None:
fileNotFound: pyqtSignal = pyqtSignal(str)
fileOpenError: pyqtSignal = pyqtSignal()
settingsError: pyqtSignal = pyqtSignal()
- fatalError: pyqtSignal = pyqtSignal(str)
fileUntitled: pyqtSignal = pyqtSignal()
fileSavedAs: pyqtSignal = pyqtSignal()
fileSaved: pyqtSignal = pyqtSignal()
diff --git a/vars.iss b/vars.iss
index e0d5d0e..2c35130 100644
--- a/vars.iss
+++ b/vars.iss
@@ -1,5 +1,5 @@
#define JAppName "JNote"
-#define JAppVersion "1.6.10"
+#define JAppVersion "1.6.11"
#define JAppPublisher "Induwara Jayaweera"
#define JAppURL "http://www.github.com/dev-i-j/jnote"
#define JAppExeName "JNote.exe"