Skip to content

Commit b694faf

Browse files
committed
errors: move error variables to errors.go
1 parent 0262a07 commit b694faf

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

errors.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2021 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 protocol
6+
7+
import "go.lsp.dev/jsonrpc2"
8+
9+
const (
10+
// ContentModified is the state change that invalidates the result of a request in execution.
11+
//
12+
// Defined by the protocol.
13+
CodeContentModified jsonrpc2.Code = -32801
14+
15+
// RequestCancelled is the cancellation error.
16+
//
17+
// Defined by the protocol.
18+
CodeRequestCancelled jsonrpc2.Code = -32800
19+
)
20+
21+
var (
22+
// ErrContentModified should be used when a request is canceled early.
23+
ErrContentModified = jsonrpc2.NewError(CodeContentModified, "cancelled JSON-RPC")
24+
25+
// ErrRequestCancelled should be used when a request is canceled early.
26+
ErrRequestCancelled = jsonrpc2.NewError(CodeRequestCancelled, "cancelled JSON-RPC")
27+
)

handler.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ import (
1212
"go.lsp.dev/pkg/xcontext"
1313
)
1414

15-
// RequestCancelledCode cancel request code.
16-
const RequestCancelledCode jsonrpc2.Code = -32800
17-
18-
// ErrRequestCancelled should be used when a request is canceled early.
19-
var ErrRequestCancelled = jsonrpc2.NewError(RequestCancelledCode, "cancelled JSON-RPC")
20-
2115
// Handlers default jsonrpc2.Handler.
2216
func Handlers(handler jsonrpc2.Handler) jsonrpc2.Handler {
2317
return CancelHandler(

0 commit comments

Comments
 (0)