Skip to content

Commit d8c3eeb

Browse files
committed
jsonrpc2: split error code to error.go
1 parent b64b361 commit d8c3eeb

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

error.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2019 The go-language-server Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package jsonrpc2
6+
7+
type ErrorCode int
8+
9+
const (
10+
ParseError ErrorCode = -32700
11+
InvalidRequest ErrorCode = -32600
12+
MethodNotFound ErrorCode = -32601
13+
InvalidParams ErrorCode = -32602
14+
InternalError ErrorCode = -32603
15+
ServerErrorStart ErrorCode = -32099
16+
ServerErrorEnd ErrorCode = -32000
17+
ServerNotInitialized ErrorCode = -32002
18+
UnknownErrorCode ErrorCode = -32001
19+
20+
// Defined by the protocol.
21+
RequestCancelled ErrorCode = -32800
22+
ContentModified ErrorCode = -32801
23+
)

jsonrpc2.go

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ type Message struct {
2121
JSONRPC string `json:"jsonrpc"`
2222
}
2323

24-
// Request is a request message to describe a request between the client and the server. Every processed request must send a response back to the sender of the request.
24+
// Request is a request message to describe a request between the client and the server.
25+
// Every processed request must send a response back to the sender of the request.
2526
type Request struct {
2627
Message
2728

@@ -35,7 +36,10 @@ type Request struct {
3536
Params *json.RawMessage `json:"params,omitempty"`
3637
}
3738

38-
// Response is a response ressage sent as a result of a request. If a request doesn't provide a result value the receiver of a request still needs to return a response message to conform to the JSON RPC specification. The result property of the ResponseMessage should be set to null in this case to signal a successful request.
39+
// Response is a response ressage sent as a result of a request.
40+
// If a request doesn't provide a result value the receiver of a request still needs to return a response message to
41+
// conform to the JSON RPC specification.
42+
// The result property of the ResponseMessage should be set to null in this case to signal a successful request.
3943
type Response struct {
4044
Message
4145

@@ -73,22 +77,3 @@ type NotificationMessage struct {
7377
// Params is the notification's params.
7478
Params interface{} `json:"params,omitempty"`
7579
}
76-
77-
type ErrorCode int
78-
79-
const (
80-
// Defined by JSON RPC
81-
ParseError ErrorCode = -32700
82-
InvalidRequest ErrorCode = -32600
83-
MethodNotFound ErrorCode = -32601
84-
InvalidParams ErrorCode = -32602
85-
InternalError ErrorCode = -32603
86-
ServerErrorStart ErrorCode = -32099
87-
ServerErrorEnd ErrorCode = -32000
88-
ServerNotInitialized ErrorCode = -32002
89-
UnknownErrorCode ErrorCode = -32001
90-
91-
// Defined by the protocol.
92-
RequestCancelled ErrorCode = -32800
93-
ContentModified ErrorCode = -32801
94-
)

0 commit comments

Comments
 (0)