mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-09-05 16:47:20 -04:00
Use panic in editNote to prevent temp files from being left behind
This commit is contained in:
+2
-4
@@ -112,15 +112,13 @@ func editNote(baseNote []string) ([]string, bool) {
|
|||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
|
panic(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the tempFile for reading
|
// open the tempFile for reading
|
||||||
tempFile, err = os.Open(tempFile.Name())
|
tempFile, err = os.Open(tempFile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(offline.AnsiError + "Failed to open temporary file (\"" + tempFile.Name() + "\") " + err.Error() + offline.AnsiReset)
|
panic(offline.AnsiError + "Failed to write note with " + editor + offline.AnsiReset)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the edited note from the tempFile
|
// read the edited note from the tempFile
|
||||||
|
|||||||
Reference in New Issue
Block a user