From f2aaf13f569f48e7a57c8610dfb33fb1ba9cb9c1 Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Sun, 6 Feb 2022 10:04:30 -0800 Subject: [PATCH] Use code strings consistently. --- error.go | 4 ++-- jrpc2_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/error.go b/error.go index c7dc9ed..7e95246 100644 --- a/error.go +++ b/error.go @@ -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"} @@ -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. diff --git a/jrpc2_test.go b/jrpc2_test.go index b2deaa8..b3d0b2b 100644 --- a/jrpc2_test.go +++ b/jrpc2_test.go @@ -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"}`, @@ -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"}]`},