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