| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 /// Error codes defined in the [JSON-RPC 2.0 specificiation][spec]. | |
| 6 /// | |
| 7 /// These codes are generally used for protocol-level communication. Most of | |
| 8 /// them shouldn't be used by the application. Those that should have | |
| 9 /// convenience constructors in [RpcException]. | |
| 10 /// | |
| 11 /// [spec]: http://www.jsonrpc.org/specification#error_object | |
| 12 library json_rpc_2.error_code; | |
| 13 | |
| 14 /// An error code indicating that invalid JSON was received by the server. | |
| 15 const PARSE_ERROR = -32700; | |
| 16 | |
| 17 /// An error code indicating that the request JSON was invalid according to the | |
| 18 /// JSON-RPC 2.0 spec. | |
| 19 const INVALID_REQUEST = -32600; | |
| 20 | |
| 21 /// An error code indicating that the requested method does not exist or is | |
| 22 /// unavailable. | |
| 23 const METHOD_NOT_FOUND = -32601; | |
| 24 | |
| 25 /// An error code indicating that the request parameters are invalid for the | |
| 26 /// requested method. | |
| 27 const INVALID_PARAMS = -32602; | |
| 28 | |
| 29 /// An internal JSON-RPC error. | |
| 30 const INTERNAL_ERROR = -32603; | |
| 31 | |
| 32 /// An unexpected error occurred on the server. | |
| 33 /// | |
| 34 /// The spec reserves the range from -32000 to -32099 for implementation-defined | |
| 35 /// server exceptions, but for now we only use one of those values. | |
| 36 const SERVER_ERROR = -32000; | |
| 37 | |
| 38 /// Returns a human-readable name for [errorCode] if it's one specified by the | |
| 39 /// JSON-RPC 2.0 spec. | |
| 40 /// | |
| 41 /// If [errorCode] isn't defined in the JSON-RPC 2.0 spec, returns null. | |
| 42 String name(int errorCode) { | |
| 43 switch (errorCode) { | |
| 44 case PARSE_ERROR: return "parse error"; | |
| 45 case INVALID_REQUEST: return "invalid request"; | |
| 46 case METHOD_NOT_FOUND: return "method not found"; | |
| 47 case INVALID_PARAMS: return "invalid parameters"; | |
| 48 case INTERNAL_ERROR: return "internal error"; | |
| 49 default: return null; | |
| 50 } | |
| 51 } | |
| OLD | NEW |