-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
codes.go
86 lines (67 loc) · 2.91 KB
/
codes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// SPDX-FileCopyrightText: 2021 The Go Language Server Authors
// SPDX-License-Identifier: BSD-3-Clause
package jsonrpc2
// Code is an error code as defined in the JSON-RPC spec.
type Code int32
// list of JSON-RPC error codes.
const (
// ParseError is the invalid JSON was received by the server.
// An error occurred on the server while parsing the JSON text.
ParseError Code = -32700
// InvalidRequest is the JSON sent is not a valid Request object.
InvalidRequest Code = -32600
// MethodNotFound is the method does not exist / is not available.
MethodNotFound Code = -32601
// InvalidParams is the invalid method parameter(s).
InvalidParams Code = -32602
// InternalError is the internal JSON-RPC error.
InternalError Code = -32603
// JSONRPCReservedErrorRangeStart is the start range of JSON RPC reserved error codes.
//
// It doesn't denote a real error code. No LSP error codes should
// be defined between the start and end range. For backwards
// compatibility the "ServerNotInitialized" and the "UnknownErrorCode"
// are left in the range.
//
// @since 3.16.0.
JSONRPCReservedErrorRangeStart Code = -32099
// CodeServerErrorStart reserved for implementation-defined server-errors.
//
// Deprecated: Use JSONRPCReservedErrorRangeStart instead.
CodeServerErrorStart = JSONRPCReservedErrorRangeStart
// ServerNotInitialized is the error of server not initialized.
ServerNotInitialized Code = -32002
// UnknownError should be used for all non coded errors.
UnknownError Code = -32001
// JSONRPCReservedErrorRangeEnd is the start range of JSON RPC reserved error codes.
//
// It doesn't denote a real error code.
//
// @since 3.16.0.
JSONRPCReservedErrorRangeEnd Code = -32000
// CodeServerErrorEnd reserved for implementation-defined server-errors.
//
// Deprecated: Use JSONRPCReservedErrorRangeEnd instead.
CodeServerErrorEnd = JSONRPCReservedErrorRangeEnd
)
// This file contains the Go forms of the wire specification.
//
// See http://www.jsonrpc.org/specification for details.
//
// list of JSON-RPC errors.
var (
// ErrUnknown should be used for all non coded errors.
ErrUnknown = NewError(UnknownError, "JSON-RPC unknown error")
// ErrParse is used when invalid JSON was received by the server.
ErrParse = NewError(ParseError, "JSON-RPC parse error")
// ErrInvalidRequest is used when the JSON sent is not a valid Request object.
ErrInvalidRequest = NewError(InvalidRequest, "JSON-RPC invalid request")
// ErrMethodNotFound should be returned by the handler when the method does
// not exist / is not available.
ErrMethodNotFound = NewError(MethodNotFound, "JSON-RPC method not found")
// ErrInvalidParams should be returned by the handler when method
// parameter(s) were invalid.
ErrInvalidParams = NewError(InvalidParams, "JSON-RPC invalid params")
// ErrInternal is not currently returned but defined for completeness.
ErrInternal = NewError(InternalError, "JSON-RPC internal error")
)