aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/common.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-12-12 15:50:15 +0100
committerGitHub <noreply@github.com>2016-12-12 15:50:15 +0100
commitdf9748cfb51db9c406e3df063badbd8c78ee819d (patch)
treec03578daefa14b14ca480c3e801ee8e225599b22 /plumbing/protocol/packp/common.go
parent3967812bd0de40330dfbb9e1a7d14d4073cc1b10 (diff)
downloadgo-git-df9748cfb51db9c406e3df063badbd8c78ee819d.tar.gz
transport: new git protocol (#175)
Diffstat (limited to 'plumbing/protocol/packp/common.go')
-rw-r--r--plumbing/protocol/packp/common.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/common.go b/plumbing/protocol/packp/common.go
index 93dfaed..ab07ac8 100644
--- a/plumbing/protocol/packp/common.go
+++ b/plumbing/protocol/packp/common.go
@@ -1,5 +1,9 @@
package packp
+import (
+ "fmt"
+)
+
type stateFn func() stateFn
const (
@@ -44,3 +48,23 @@ var (
func isFlush(payload []byte) bool {
return len(payload) == 0
}
+
+// ErrUnexpectedData represents an unexpected data decoding a message
+type ErrUnexpectedData struct {
+ Msg string
+ Data []byte
+}
+
+// NewErrUnexpectedData returns a new ErrUnexpectedData containing the data and
+// the message given
+func NewErrUnexpectedData(msg string, data []byte) error {
+ return &ErrUnexpectedData{Msg: msg, Data: data}
+}
+
+func (err *ErrUnexpectedData) Error() string {
+ if len(err.Data) == 0 {
+ return err.Msg
+ }
+
+ return fmt.Sprintf("%s (%s)", err.Msg, err.Data)
+}