1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-03 04:38:38 -04:00

testing: Make handlers.Error obey the standard 'error' interface

And return these types from test helper functions
This commit is contained in:
2017-10-09 21:10:59 -04:00
parent 32ac18647b
commit 4953063286
2 changed files with 9 additions and 5 deletions

View File

@ -2,6 +2,7 @@ package handlers
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
@ -12,6 +13,10 @@ type Error struct {
ErrorString string
}
func (e *Error) Error() string {
return fmt.Sprintf("Error %d: %s", e.ErrorId, e.ErrorString)
}
func (e *Error) Read(json_str string) error {
dec := json.NewDecoder(strings.NewReader(json_str))
return dec.Decode(e)