Skip to content

Commit b5c5420

Browse files
committed
error: rename New to NewError
1 parent 70b024a commit b5c5420

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (e *Error) Unwrap() error {
9292
}
9393

9494
// New builds a Error struct for the suppied message and code.
95-
func New(c Code, args ...interface{}) *Error {
95+
func NewError(c Code, args ...interface{}) *Error {
9696
e := &Error{
9797
Code: c,
9898
Message: fmt.Sprint(args...),

jsonrpc2.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ type pendingMap map[ID]chan *Response
120120
type handlingMap map[ID]handling
121121

122122
var (
123-
errLoadPendingMap = New(CodeInternalError, "failed to Load pendingMap")
124-
errLoadhandlingMap = New(CodeInternalError, "failed to Load handlingMap")
123+
errLoadPendingMap = NewError(CodeInternalError, "failed to Load pendingMap")
124+
errLoadhandlingMap = NewError(CodeInternalError, "failed to Load handlingMap")
125125
)
126126

127127
// NewConn creates a new connection object that reads and writes messages from
@@ -244,7 +244,7 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface
244244
// Reply sends a reply to the given request.
245245
func (c *Conn) Reply(ctx context.Context, req *Request, result interface{}, err error) error {
246246
if req.IsNotify() {
247-
return New(CodeInvalidRequest, "reply not invoked with a valid call")
247+
return NewError(CodeInvalidRequest, "reply not invoked with a valid call")
248248
}
249249

250250
m, ok := c.handling.Load().(handlingMap)
@@ -267,7 +267,7 @@ func (c *Conn) Reply(ctx context.Context, req *Request, result interface{}, err
267267
return err
268268
}
269269
} else {
270-
resp.Error = New(CodeParseError, err)
270+
resp.Error = NewError(CodeParseError, err)
271271
}
272272

273273
data, err := gojay.MarshalJSONObject(resp)
@@ -462,7 +462,7 @@ func (c *Conn) Run(ctx context.Context) (err error) {
462462
close(rchan)
463463

464464
default:
465-
c.logger.Error(Receive, zap.Error(Errorf(CodeInvalidParams, "message not a call, notify or response, ignoring")))
465+
c.logger.Error(Receive, zap.Error(NewError(CodeInvalidParams, "message not a call, notify or response, ignoring")))
466466
}
467467
}
468468
}

0 commit comments

Comments
 (0)