From 2252be1463186d76f0e4b57b36ebf86e503aca1b Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Fri, 8 Mar 2024 12:57:10 -0500 Subject: [PATCH] Use panic in editNote to prevent temp files from being left behind --- src/cli/edit.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cli/edit.go b/src/cli/edit.go index a4ae86f..28809f7 100644 --- a/src/cli/edit.go +++ b/src/cli/edit.go @@ -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