aboutsummaryrefslogtreecommitdiff
path: root/hotline
diff options
context:
space:
mode:
Diffstat (limited to 'hotline')
-rw-r--r--hotline/client.go34
-rw-r--r--hotline/transaction.go5
2 files changed, 39 insertions, 0 deletions
diff --git a/hotline/client.go b/hotline/client.go
index c322562..83bcfab 100644
--- a/hotline/client.go
+++ b/hotline/client.go
@@ -237,7 +237,41 @@ func handleTranServerMsg(c *Client, t *Transaction) (res []Transaction, err erro
return res, err
}
+func (c *Client) showErrMsg(msg string) {
+ time := time.Now().Format(time.RFC850)
+
+ title := "| Error |"
+
+ msgBox := tview.NewTextView().SetScrollable(true)
+ msgBox.SetText(msg).SetBackgroundColor(tcell.ColorDarkRed)
+ msgBox.SetTitle(title).SetBorder(true)
+ msgBox.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
+ switch event.Key() {
+ case tcell.KeyEscape:
+ c.UI.Pages.RemovePage("serverMsgModal" + time)
+ }
+ return event
+ })
+
+ centeredFlex := tview.NewFlex().
+ AddItem(nil, 0, 1, false).
+ AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
+ AddItem(nil, 0, 1, false).
+ AddItem(msgBox, 0, 2, true).
+ AddItem(nil, 0, 1, false), 0, 2, true).
+ AddItem(nil, 0, 1, false)
+
+ c.UI.Pages.AddPage("serverMsgModal"+time, centeredFlex, true, true)
+ c.UI.App.Draw() // TODO: errModal doesn't render without this. wtf?
+}
+
func handleGetFileNameList(c *Client, t *Transaction) (res []Transaction, err error) {
+ if t.IsError() {
+ c.showErrMsg(string(t.GetField(fieldError).Data))
+ c.Logger.Infof("Error: %s", t.GetField(fieldError).Data)
+ return res, err
+ }
+
fTree := tview.NewTreeView().SetTopLevel(1)
root := tview.NewTreeNode("Root")
fTree.SetRoot(root).SetCurrentNode(root)
diff --git a/hotline/transaction.go b/hotline/transaction.go
index 88e17df..9b0ac40 100644
--- a/hotline/transaction.go
+++ b/hotline/transaction.go
@@ -1,6 +1,7 @@
package hotline
import (
+ "bytes"
"encoding/binary"
"errors"
"fmt"
@@ -238,3 +239,7 @@ func (t *Transaction) GetField(id int) Field {
return Field{}
}
+
+func (t *Transaction) IsError() bool {
+ return bytes.Compare(t.ErrorCode, []byte{0, 0, 0, 1}) == 0
+}