From 472d7b0d3b614b65803b96344d5e4053bf794fa3 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Wed, 25 Sep 2019 20:59:15 -0400 Subject: [PATCH] Upload/Download update for error handling --- main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index fc91430..7903dd4 100644 --- a/main.go +++ b/main.go @@ -97,12 +97,21 @@ func formatOutput(api keybase.ChatAPI) string { } func uploadFile(g *gocui.Gui, fileName string, fileTitle string) { chat := k.NewChat(channel) - chat.Upload(fileTitle, fileName) - printToView(g, "Feed", fmt.Sprintf("You have uploaded %s to %s", fileName, channel.Name)) + _, err := chat.Upload(fileTitle, fileName) + if err != nil { + printToView(g, "Feed", fmt.Sprintf("There was an error uploading %s to %s", fileName, channel.Name)) + } else { + printToView(g, "Feed", fmt.Sprintf("Uploaded %s to %s", fileName, channel.Name)) + } } func downloadFile(g *gocui.Gui, messageID int, fileName string) { chat := k.NewChat(channel) - chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName)) + _, err := chat.Download(messageID, fmt.Sprintf("%s/%s", downloadPath, fileName)) + if err != nil { + printToView(g, "Feed", fmt.Sprintf("There was an error downloading %s from %s", fileName, channel.Name)) + } else { + printToView(g, "Feed", fmt.Sprintf("Downloaded %s from %s", fileName, channel.Name)) + } } func populateList(g *gocui.Gui) {