diff --git a/internal/jsonrpc2_v2/messages.go b/internal/jsonrpc2_v2/messages.go index af145641d6a..f02b879c3f2 100644 --- a/internal/jsonrpc2_v2/messages.go +++ b/internal/jsonrpc2_v2/messages.go @@ -96,17 +96,17 @@ func (msg *Response) marshal(to *wireCombined) { to.Result = msg.Result } -func toWireError(err error) *wireError { +func toWireError(err error) *WireError { if err == nil { // no error, the response is complete return nil } - if err, ok := err.(*wireError); ok { + if err, ok := err.(*WireError); ok { // already a wire error, just use it return err } - result := &wireError{Message: err.Error()} - var wrapped *wireError + result := &WireError{Message: err.Error()} + var wrapped *WireError if errors.As(err, &wrapped) { // if we wrapped a wire error, keep the code from the wrapped error // but the message from the outer error diff --git a/internal/jsonrpc2_v2/wire.go b/internal/jsonrpc2_v2/wire.go index c8dc9ebf1bf..8f60fc62766 100644 --- a/internal/jsonrpc2_v2/wire.go +++ b/internal/jsonrpc2_v2/wire.go @@ -49,11 +49,11 @@ type wireCombined struct { Method string `json:"method,omitempty"` Params json.RawMessage `json:"params,omitempty"` Result json.RawMessage `json:"result,omitempty"` - Error *wireError `json:"error,omitempty"` + Error *WireError `json:"error,omitempty"` } -// wireError represents a structured error in a Response. -type wireError struct { +// WireError represents a structured error in a Response. +type WireError struct { // Code is an error code indicating the type of failure. Code int64 `json:"code"` // Message is a short description of the error. @@ -67,18 +67,18 @@ type wireError struct { // only be used to build errors for application specific codes as allowed by the // specification. func NewError(code int64, message string) error { - return &wireError{ + return &WireError{ Code: code, Message: message, } } -func (err *wireError) Error() string { +func (err *WireError) Error() string { return err.Message } -func (err *wireError) Is(other error) bool { - w, ok := other.(*wireError) +func (err *WireError) Is(other error) bool { + w, ok := other.(*WireError) if !ok { return false }