Add InvalidTypeError

pull/579/head
Taylor Gerring 10 years ago
parent c139af5826
commit ca03e97697
  1. 16
      rpc/messages.go
  2. 9
      rpc/messages_test.go

@ -21,6 +21,22 @@ import (
"fmt" "fmt"
) )
type InvalidTypeError struct {
method string
msg string
}
func (e *InvalidTypeError) Error() string {
return fmt.Sprintf("invalid type on field %s: %s", e.method, e.msg)
}
func NewInvalidTypeError(method, msg string) *InvalidTypeError {
return &InvalidTypeError{
method: method,
msg: msg,
}
}
type InsufficientParamsError struct { type InsufficientParamsError struct {
have int have int
want int want int

@ -4,6 +4,15 @@ import (
"testing" "testing"
) )
func TestInvalidTypeError(t *testing.T) {
err := NewInvalidTypeError("testField", "not string")
expected := "invalid type on field testField: not string"
if err.Error() != expected {
t.Error(err.Error())
}
}
func TestInsufficientParamsError(t *testing.T) { func TestInsufficientParamsError(t *testing.T) {
err := NewInsufficientParamsError(0, 1) err := NewInsufficientParamsError(0, 1)
expected := "insufficient params, want 1 have 0" expected := "insufficient params, want 1 have 0"

Loading…
Cancel
Save