Skip to content

Commit

Permalink
Use code strings consistently.
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Feb 6, 2022
1 parent 3d060b0 commit f2aaf13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var errClientStopped = errors.New("the client has been stopped")
var errEmptyMethod = &Error{Code: code.InvalidRequest, Message: "empty method name"}

// errNoSuchMethod is the error reported for an unknown method name.
var errNoSuchMethod = &Error{Code: code.MethodNotFound, Message: "no such method"}
var errNoSuchMethod = &Error{Code: code.MethodNotFound, Message: code.MethodNotFound.String()}

// errDuplicateID is the error reported for a duplicated request ID.
var errDuplicateID = &Error{Code: code.InvalidRequest, Message: "duplicate request ID"}
Expand All @@ -59,7 +59,7 @@ var errInvalidRequest = &Error{Code: code.ParseError, Message: "invalid request
var errEmptyBatch = &Error{Code: code.InvalidRequest, Message: "empty request batch"}

// errInvalidParams is the error reported for invalid request parameters.
var errInvalidParams = &Error{Code: code.InvalidParams, Message: "invalid parameters"}
var errInvalidParams = &Error{Code: code.InvalidParams, Message: code.InvalidParams.String()}

// ErrConnClosed is returned by a server's push-to-client methods if they are
// called after the client connection is closed.
Expand Down
4 changes: 2 additions & 2 deletions jrpc2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func TestServer_nonLibraryClient(t *testing.T) {

// The method specified doesn't exist.
{`{"jsonrpc":"2.0", "id": 3, "method": "NoneSuch"}`,
`{"jsonrpc":"2.0","id":3,"error":{"code":-32601,"message":"no such method","data":"NoneSuch"}}`},
`{"jsonrpc":"2.0","id":3,"error":{"code":-32601,"message":"method not found","data":"NoneSuch"}}`},

// The parameters are of the wrong form.
{`{"jsonrpc":"2.0", "id": 4, "method": "X", "params": "bogus"}`,
Expand Down Expand Up @@ -654,7 +654,7 @@ func TestServer_nonLibraryClient(t *testing.T) {

// A batch of invalid requests returns a batch of errors.
{`[{"jsonrpc": "2.0", "id": 6, "method":"bogus"}]`,
`[{"jsonrpc":"2.0","id":6,"error":{"code":-32601,"message":"no such method","data":"bogus"}}]`},
`[{"jsonrpc":"2.0","id":6,"error":{"code":-32601,"message":"method not found","data":"bogus"}}]`},

// Batch requests return batch responses, even for a singleton.
{`[{"jsonrpc": "2.0", "id": 7, "method": "X"}]`, `[{"jsonrpc":"2.0","id":7,"result":"OK"}]`},
Expand Down

0 comments on commit f2aaf13

Please sign in to comment.