Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
v1.6.11 - Improve Fatal Error Dialog [build]
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-I-J committed Dec 17, 2020
1 parent 541cda9 commit 792266e
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 55 deletions.
30 changes: 15 additions & 15 deletions .debug/jnote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion data/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1>JNote - A Free NotePad</h1>
<p><img alt="JNote Logo" src="icons/logo.png" /></p>
<p><strong>JNote is a free NotePad</strong> application written in <em>Python and QML (PyQt5).</em> Binaries are available for Windows and Mac, but you can <em>build from source</em> for Linux (See Below).</p>
<h2>Features</h2>
<p>The current version is v1.6.10 and additional for basic functions of a note pad, it can</p>
<p>The current version is v1.6.11 and additional for basic functions of a note pad, it can</p>
<ul>
<li>Automatically Check For Updates,</li>
<li>Determine A File Is Binary Or Not And Show Message,</li>
Expand Down
20 changes: 10 additions & 10 deletions fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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 ""
30 changes: 15 additions & 15 deletions jnote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
}

Expand Down Expand Up @@ -1128,6 +1131,7 @@ ApplicationWindow {
}

function onRegexError(regex, error) {
statusText.text = "Invalid Regular Expression - \"" + regex + "\"!"
regexError.regex = regex
regexError.error = error
regexError.open()
Expand Down
16 changes: 8 additions & 8 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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]:
Expand All @@ -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 {}
2 changes: 1 addition & 1 deletion settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ italic = false
[last-used-file]
untitled = true
path = ""
text = ""
text = "["
encoding = "utf-8"
2 changes: 1 addition & 1 deletion signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion vars.iss
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 792266e

Please sign in to comment.