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:
@ -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)
|
||||
|
Reference in New Issue
Block a user