|
| 1 | +// Copyright 2020 The Go Language Server Authors |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +package jsonrpc2 |
| 5 | + |
| 6 | +// Code is an int64 error code as defined in the JSON-RPC spec. |
| 7 | +type Code int64 |
| 8 | + |
| 9 | +// list of JSON-RPC error codes. |
| 10 | +const ( |
| 11 | + // ParseError is the invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. |
| 12 | + ParseError Code = -32700 |
| 13 | + |
| 14 | + // InvalidRequest is the JSON sent is not a valid Request object. |
| 15 | + InvalidRequest Code = -32600 |
| 16 | + |
| 17 | + // MethodNotFound is the method does not exist / is not available. |
| 18 | + MethodNotFound Code = -32601 |
| 19 | + |
| 20 | + // InvalidParams is the invalid method parameter(s). |
| 21 | + InvalidParams Code = -32602 |
| 22 | + |
| 23 | + // InternalError is the internal JSON-RPC error. |
| 24 | + InternalError Code = -32603 |
| 25 | + |
| 26 | + // ServerNotInitialized is the error of server not initialized. |
| 27 | + ServerNotInitialized Code = -32002 |
| 28 | + |
| 29 | + // UnknownError should be used for all non coded errors. |
| 30 | + UnknownError Code = -32001 |
| 31 | + |
| 32 | + // RequestCancelled is the cancellation error. |
| 33 | + // |
| 34 | + // Defined by the Language Server Protocol. |
| 35 | + RequestCancelled Code = -32800 |
| 36 | + |
| 37 | + // ContentModified is the state change that invalidates the result of a request in execution. |
| 38 | + // |
| 39 | + // Defined by the Language Server Protocol. |
| 40 | + ContentModified Code = -32801 |
| 41 | + |
| 42 | + // ServerOverloaded is returned when a message was refused due to a |
| 43 | + // server being temporarily unable to accept any new messages. |
| 44 | + ServerOverloaded Code = -32000 |
| 45 | + |
| 46 | + codeServerErrorStart Code = -32099 |
| 47 | + codeServerErrorEnd Code = -32000 |
| 48 | +) |
| 49 | + |
| 50 | +// list of JSON-RPC errors. |
| 51 | +var ( |
| 52 | + // ErrUnknown should be used for all non coded errors. |
| 53 | + ErrUnknown = Error{Code: UnknownError, Message: "JSON-RPC unknown error"} |
| 54 | + |
| 55 | + // ErrParse is used when invalid JSON was received by the server. |
| 56 | + ErrParse = Error{Code: ParseError, Message: "JSON-RPC parse error"} |
| 57 | + |
| 58 | + // ErrInvalidRequest is used when the JSON sent is not a valid Request object. |
| 59 | + ErrInvalidRequest = Error{Code: InvalidRequest, Message: "JSON-RPC invalid request"} |
| 60 | + |
| 61 | + // ErrMethodNotFound should be returned by the handler when the method does |
| 62 | + // not exist / is not available. |
| 63 | + ErrMethodNotFound = Error{Code: MethodNotFound, Message: "JSON-RPC method not found"} |
| 64 | + |
| 65 | + // ErrInvalidParams should be returned by the handler when method |
| 66 | + // parameter(s) were invalid. |
| 67 | + ErrInvalidParams = Error{Code: InvalidParams, Message: "JSON-RPC invalid params"} |
| 68 | + |
| 69 | + // ErrInternal is not currently returned but defined for completeness. |
| 70 | + ErrInternal = Error{Code: InternalError, Message: "JSON-RPC internal error"} |
| 71 | + |
| 72 | + // ErrServerOverloaded is returned when a message was refused due to a |
| 73 | + // server being temporarily unable to accept any new messages. |
| 74 | + ErrServerOverloaded = Error{Code: ServerOverloaded, Message: "JSON-RPC overloaded"} |
| 75 | + |
| 76 | + // ErrIdleTimeout is returned when serving timed out waiting for new connections. |
| 77 | + ErrIdleTimeout = constErr("timed out waiting for new connections") |
| 78 | +) |
0 commit comments