Debian Codegraph @

internal/jsonrpc2_v2/wire.go

raw symbols SCIP
1 // Copyright 2018 The Go 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 jsonrpc2scip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/
6
7 import (
8 "encoding/jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/"
9 )
10
11 // This file contains the go forms of the wire specification.
12 // see http://www.jsonrpc.org/specification for details
13
14 var (
15 // ErrParse is used when invalid JSON was received by the server.
16 ErrParsescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrParse. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32700, "JSON RPC parse error")
17 // ErrInvalidRequest is used when the JSON sent is not a valid Request object.
18 ErrInvalidRequestscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInvalidRequest. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32600, "JSON RPC invalid request")
19 // ErrMethodNotFound should be returned by the handler when the method does
20 // not exist / is not available.
21 ErrMethodNotFoundscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrMethodNotFound. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32601, "JSON RPC method not found")
22 // ErrInvalidParams should be returned by the handler when method
23 // parameter(s) were invalid.
24 ErrInvalidParamsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInvalidParams. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32602, "JSON RPC invalid params")
25 // ErrInternal indicates a failure to process a call correctly
26 ErrInternalscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrInternal. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32603, "JSON RPC internal error")
27
28 // The following errors are not part of the json specification, but
29 // compliant extensions specific to this implementation.
30
31 // ErrServerOverloaded is returned when a message was refused due to a
32 // server being temporarily unable to accept any new messages.
33 ErrServerOverloadedscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrServerOverloaded. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32000, "JSON RPC overloaded")
34 // ErrUnknown should be used for all non coded errors.
35 ErrUnknownscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrUnknown. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32001, "JSON RPC unknown error")
36 // ErrServerClosing is returned for calls that arrive while the server is closing.
37 ErrServerClosingscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrServerClosing. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32002, "JSON RPC server is closing")
38 // ErrClientClosing is a dummy error returned for calls initiated while the client is closing.
39 ErrClientClosingscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/ErrClientClosing. = NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(-32003, "JSON RPC client is closing")
40 )
41
42 const wireVersionscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireVersion. = "2.0"
43
44 // wireCombined has all the fields of both Request and Response.
45 // We can decode this and then work out which it is.
46 type wireCombinedscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined# struct {
47 VersionTagscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#VersionTag. string `json:"jsonrpc"`
48 IDscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#ID. any `json:"id,omitempty"`
49 Methodscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#Method. string `json:"method,omitempty"`
50 Paramsscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#Params. jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/RawMessage# `json:"params,omitempty"`
51 Resultscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#Result. jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/RawMessage# `json:"result,omitempty"`
52 Errorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/wireCombined#Error. *WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError# `json:"error,omitempty"`
53 }
54
55 // WireError represents a structured error in a Response.
56 type WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError# struct {
57 // Code is an error code indicating the type of failure.
58 Codescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Code. int64 `json:"code"`
59 // Message is a short description of the error.
60 Messagescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Message. string `json:"message"`
61 // Data is optional structured data containing additional information about the error.
62 Datascip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Data. jsonscip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/.RawMessagescip-go gomod github.com/golang/go/src go1.25.0 `encoding/json`/RawMessage# `json:"data,omitempty"`
63 }
64
65 // NewError returns an error that will encode on the wire correctly.
66 // The standard codes are made available from this package, this function should
67 // only be used to build errors for application specific codes as allowed by the
68 // specification.
69 func NewErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/NewError().(code int64, message string) error {
70 return &WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#{
71 Codescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Code.: code,
72 Messagescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Message.: message,
73 }
74 }
75
76 func (err *WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#) Errorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Error().() string {
77 return err.Messagescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Message.
78 }
79
80 func (err *WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#) Isscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Is().(other error) bool {
81 w, ok := other.(*WireErrorscip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#)
82 if !ok {
83 return false
84 }
85 return err.Codescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Code. == w.Codescip-go gomod golang.org/x/tools . `golang.org/x/tools/internal/jsonrpc2_v2`/WireError#Code.
86 }