Use panic in editNote to prevent temp files from being left behind

This commit is contained in:
2024-03-08 12:57:10 -05:00
parent 05a15260fd
commit 81a4fca89d
+2 -4
View File
@@ -112,15 +112,13 @@ func editNote(baseNote []string) ([]string, bool) {
cmd.Stderr = os.Stderr
err := cmd.Run()
if err != nil {
fmt.Println(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
os.Exit(1)
panic(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
}
// open the tempFile for reading
tempFile, err = os.Open(tempFile.Name())
if err != nil {
fmt.Println(offline.AnsiError + "Failed to open temporary file (\"" + tempFile.Name() + "\") " + err.Error() + offline.AnsiReset)
os.Exit(1)
panic(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
}
// read the edited note from the tempFile