commands: Added an Error struct for creating marshallable errors
Matt Bell committed
Oct 10, 2014 at 12:54 UTC
95b0dd29f84cee80f4fcc139f7997817490de692
1 file changed
+10
commands/response.go
+10
@@ -7,6 +7,12 @@ const (
7
// TODO: add more types of errors for better error-specific handling
8
)
9
10
+// Error is a struct for marshalling errors
11
+type Error struct {
12
+ message string
13
+ code ErrorType
14
+}
15
+
16
type Response struct {
17
req *Request
18
Error error
@@ -19,6 +25,10 @@ func (r *Response) SetError(err error, errType ErrorType) {
25
r.ErrorType = errType
26
}
27
28
+func (r *Response) FormatError() Error {
29
+ return Error{ r.Error.Error(), r.ErrorType }
30
+}
31
+
32
/*func (r *Response) Encode() ([]byte, error) {
33
34
}*/