Skip to content

Commit 33e9882

Browse files
committed
error: add Code suffix
1 parent ea56ede commit 33e9882

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

error.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ import (
1111
type ErrorCode int64
1212

1313
const (
14-
ParseError ErrorCode = -32700
15-
InvalidRequest ErrorCode = -32600
16-
MethodNotFound ErrorCode = -32601
17-
InvalidParams ErrorCode = -32602
18-
InternalError ErrorCode = -32603
19-
ServerErrorStart ErrorCode = -32099
20-
ServerErrorEnd ErrorCode = -32000
21-
ServerNotInitialized ErrorCode = -32002
22-
UnknownErrorCode ErrorCode = -32001
14+
CodeParseError ErrorCode = -32700
15+
CodeInvalidRequest ErrorCode = -32600
16+
CodeMethodNotFound ErrorCode = -32601
17+
CodeInvalidParams ErrorCode = -32602
18+
CodeInternalError ErrorCode = -32603
19+
CodeServerErrorStart ErrorCode = -32099
20+
CodeServerErrorEnd ErrorCode = -32000
21+
CodeServerNotInitialized ErrorCode = -32002
22+
CodeUnknownErrorCode ErrorCode = -32001
2323

2424
// Defined by the protocol.
25-
RequestCancelled ErrorCode = -32800
26-
ContentModified ErrorCode = -32801
25+
CodeRequestCancelled ErrorCode = -32800
26+
CodeContentModified ErrorCode = -32801
2727
)
2828

2929
// Error

jsonrpc2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewConn(ctx context.Context, s Stream, options ...Options) *Conn {
8282
// the default handler reports a method error
8383
conn.handle = func(ctx context.Context, c *Conn, r *Request) {
8484
if r.IsNotify() {
85-
c.Reply(ctx, r, nil, Errorf(MethodNotFound, "method %q not found", r.Method))
85+
c.Reply(ctx, r, nil, Errorf(CodeMethodNotFound, "method %q not found", r.Method))
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)