1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-27 13:48:49 +08:00

Adding an "Error" event type.

This commit is contained in:
Jakub Sobon 2018-04-02 00:43:55 +02:00
parent 1911e2190a
commit 19fb73bc55
No known key found for this signature in database
GPG Key ID: F2451A77FB05D3B7
2 changed files with 15 additions and 0 deletions

View File

@ -277,6 +277,7 @@ func TestDraw(t *testing.T) {
return ft return ft
}, },
}, },
// TODO(mum4k): Tests where widget removes children and vice versa.
} }
for _, tc := range tests { for _, tc := range tests {

View File

@ -1,6 +1,7 @@
package terminalapi package terminalapi
import ( import (
"errors"
"image" "image"
"github.com/mum4k/termdash/keyboard" "github.com/mum4k/termdash/keyboard"
@ -46,3 +47,16 @@ type Mouse struct {
} }
func (*Mouse) isEvent() {} func (*Mouse) isEvent() {}
// Error is an event indicating an error while processing input.
type Error string
func (*Error) isEvent() {}
// Error returns the error that occurred.
func (e *Error) Error() error {
if e == nil || *e == "" {
return nil
}
return errors.New(e)
}