From 95b0dd29f84cee80f4fcc139f7997817490de692 Mon Sep 17 00:00:00 2001 From: Matt Bell <mappum@gmail.com> Date: Fri, 10 Oct 2014 12:54:04 -0700 Subject: [PATCH] commands: Added an Error struct for creating marshallable errors --- commands/response.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commands/response.go b/commands/response.go index 6a60f143..a538814c 100644 --- a/commands/response.go +++ b/commands/response.go @@ -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) { }*/ -- GitLab