Remove ErrMsg and ModelAssertionErr

This commit is contained in:
Christian Rocha
2020-04-22 11:00:30 -04:00
parent aa6d766e42
commit f93b752fcc
3 changed files with 30 additions and 54 deletions

27
tea.go
View File

@@ -1,7 +1,6 @@
package tea
import (
"errors"
"io"
"os"
"strings"
@@ -94,32 +93,6 @@ type Program struct {
subscriptions Subscriptions
}
// ErrMsg is just a regular message containing an error. We handle it in Update
// just like a regular message by case switching. Of course, the developer
// could also define her own errors as well.
type ErrMsg struct {
error
}
// String implements String() on the error interface for ErrMsg
func (e ErrMsg) String() string {
return e.Error()
}
// NewErrMsg is a convenience function for creating a generic ErrMsg
func NewErrMsg(s string) ErrMsg {
return ErrMsg{errors.New(s)}
}
// NewErrMsgFromErr is a convenience function for creating an ErrMsg from an
// existing error
func NewErrMsgFromErr(e error) ErrMsg {
return ErrMsg{e}
}
// ModelAssertionErr can be used when a model assertion didn't go as planned
var ModelAssertionErr = NewErrMsg("could not perform assertion on model")
// Quit is a command that tells the program to exit
func Quit() Msg {
return quitMsg{}