aboutsummaryrefslogtreecommitdiff
path: root/editing.go
diff options
context:
space:
mode:
authorAria <me@aria.rip>2023-02-03 15:48:00 +0000
committerAria <me@aria.rip>2023-02-03 15:48:00 +0000
commit15c9b9308d353d558f7c4fc2fe03012afc84be40 (patch)
treefaff8319ffc87d10447274a12751ddc43216649d /editing.go
parent8c3b1aee5a253416523de78877ae03c3868cc62c (diff)
better error handling
Diffstat (limited to 'editing.go')
-rw-r--r--editing.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/editing.go b/editing.go
index f5369d3..3ce6fd0 100644
--- a/editing.go
+++ b/editing.go
@@ -1,6 +1,7 @@
package main
import (
+ "fmt"
"os"
"os/exec"
@@ -43,6 +44,9 @@ func (m detailsModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// exit without saving
return m.returnTo, m.returnTo.Init()
}
+ case fatalErrorMsg:
+ fmt.Printf("encountered fatal error: %s\n", msg.Error())
+ return m, tea.Quit
}
m.ti, cmd = m.ti.Update(msg)
return m, cmd
@@ -70,7 +74,7 @@ func saveSnippetCmd(snippet snippetDetails) tea.Cmd {
return func() tea.Msg {
err := saveSnippet(snippet)
if err != nil {
- panic(err)
+ return fatalErrorMsg(err)
}
return updateListMsg{}
@@ -97,7 +101,7 @@ func deleteItemCmd(item item) tea.Cmd {
return func() tea.Msg {
err := deleteItem(item)
if err != nil {
- panic(err)
+ return fatalErrorMsg(err)
}
return updateListMsg{}