internal/jsonrpc2*: remove usage of golang.org/x/xerrors
As of golang/go#50827, gopls no longer needs to build at Go 1.12. This was the only reason to continue using xerrors in the jsonrpc2 libraries. Remove this usage as a step toward eliminating the xerrors dependency from x/tools. For golang/go#52442 Change-Id: I1a0a1bbf57e6606c66b99b27439adf6f65c26a60 Reviewed-on: https://go-review.googlesource.com/c/tools/+/401155 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
bc1b54354a
commit
bdd1f89abd
1 changed files with 35 additions and 40 deletions
|
|
@ -14,7 +14,6 @@ import (
|
|||
"golang.org/x/tools/internal/event"
|
||||
"golang.org/x/tools/internal/event/label"
|
||||
"golang.org/x/tools/internal/lsp/debug/tag"
|
||||
errors "golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
// Binder builds a connection configuration.
|
||||
|
|
@ -126,7 +125,7 @@ func newConnection(ctx context.Context, rwc io.ReadWriteCloser, binder Binder) (
|
|||
func (c *Connection) Notify(ctx context.Context, method string, params interface{}) error {
|
||||
notify, err := NewNotification(method, params)
|
||||
if err != nil {
|
||||
return errors.Errorf("marshaling notify parameters: %v", err)
|
||||
return fmt.Errorf("marshaling notify parameters: %v", err)
|
||||
}
|
||||
ctx, done := event.Start(ctx, method,
|
||||
tag.Method.Of(method),
|
||||
|
|
@ -158,7 +157,7 @@ func (c *Connection) Call(ctx context.Context, method string, params interface{}
|
|||
call, err := NewCall(result.id, method, params)
|
||||
if err != nil {
|
||||
//set the result to failed
|
||||
result.resultBox <- asyncResult{err: errors.Errorf("marshaling call parameters: %w", err)}
|
||||
result.resultBox <- asyncResult{err: fmt.Errorf("marshaling call parameters: %w", err)}
|
||||
return result
|
||||
}
|
||||
ctx, endSpan := event.Start(ctx, method,
|
||||
|
|
@ -408,7 +407,7 @@ func (c *Connection) deliverMessages(ctx context.Context, handler Handler, fromQ
|
|||
switch {
|
||||
case rerr == ErrNotHandled:
|
||||
// message not handled, report it back to the caller as an error
|
||||
c.reply(entry, nil, errors.Errorf("%w: %q", ErrMethodNotFound, entry.request.Method))
|
||||
c.reply(entry, nil, fmt.Errorf("%w: %q", ErrMethodNotFound, entry.request.Method))
|
||||
case rerr == ErrAsyncResponse:
|
||||
// message handled but the response will come later
|
||||
default:
|
||||
|
|
@ -440,7 +439,7 @@ func (c *Connection) respond(entry *incoming, result interface{}, rerr error) er
|
|||
// send the response
|
||||
if result == nil && rerr == nil {
|
||||
// call with no response, send an error anyway
|
||||
rerr = errors.Errorf("%w: %q produced no response", ErrInternal, entry.request.Method)
|
||||
rerr = fmt.Errorf("%w: %q produced no response", ErrInternal, entry.request.Method)
|
||||
}
|
||||
var response *Response
|
||||
response, err = NewResponse(entry.request.ID, result, rerr)
|
||||
|
|
@ -452,11 +451,11 @@ func (c *Connection) respond(entry *incoming, result interface{}, rerr error) er
|
|||
switch {
|
||||
case rerr != nil:
|
||||
// notification failed
|
||||
err = errors.Errorf("%w: %q notification failed: %v", ErrInternal, entry.request.Method, rerr)
|
||||
err = fmt.Errorf("%w: %q notification failed: %v", ErrInternal, entry.request.Method, rerr)
|
||||
rerr = nil
|
||||
case result != nil:
|
||||
//notification produced a response, which is an error
|
||||
err = errors.Errorf("%w: %q produced unwanted response", ErrInternal, entry.request.Method)
|
||||
err = fmt.Errorf("%w: %q produced unwanted response", ErrInternal, entry.request.Method)
|
||||
default:
|
||||
// normal notification finish
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue