internal/jsonrpc2_v2: export WireError type

This makes it possible for users of the package to us the optional error
data field in error construction and error handling logic.

Updates golang/go#64882

Change-Id: Iaa554f42ff42a0b7355605ba0b49ac67f623da15
Reviewed-on: https://go-review.googlesource.com/c/tools/+/562575
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/jsonrpc2_v2/messages.go b/internal/jsonrpc2_v2/messages.go
index af14564..f02b879 100644
--- a/internal/jsonrpc2_v2/messages.go
+++ b/internal/jsonrpc2_v2/messages.go
@@ -96,17 +96,17 @@
 	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 c8dc9eb..8f60fc6 100644
--- a/internal/jsonrpc2_v2/wire.go
+++ b/internal/jsonrpc2_v2/wire.go
@@ -49,11 +49,11 @@
 	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 @@
 // 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
 	}