commands: Added an Error struct for creating marshallable errors

This commit is contained in:
Matt Bell 2014-10-10 12:54:04 -07:00 committed by Juan Batiz-Benet
parent d1595ce34c
commit 95b0dd29f8

View File

@ -7,6 +7,12 @@ const (
// TODO: add more types of errors for better error-specific handling
)
// Error is a struct for marshalling errors
type Error struct {
message string
code ErrorType
}
type Response struct {
req *Request
Error error
@ -19,6 +25,10 @@ func (r *Response) SetError(err error, errType ErrorType) {
r.ErrorType = errType
}
func (r *Response) FormatError() Error {
return Error{ r.Error.Error(), r.ErrorType }
}
/*func (r *Response) Encode() ([]byte, error) {
}*/