OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Error codes defined in the [JSON-RPC 2.0 specificiation][spec]. | 5 /// Error codes defined in the [JSON-RPC 2.0 specificiation][spec]. |
6 /// | 6 /// |
7 /// These codes are generally used for protocol-level communication. Most of | 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 | 8 /// them shouldn't be used by the application. Those that should have |
9 /// convenience constructors in [RpcException]. | 9 /// convenience constructors in [RpcException]. |
10 /// | 10 /// |
(...skipping 16 matching lines...) Expand all Loading... | |
27 const INVALID_PARAMS = -32602; | 27 const INVALID_PARAMS = -32602; |
28 | 28 |
29 /// An internal JSON-RPC error. | 29 /// An internal JSON-RPC error. |
30 const INTERNAL_ERROR = -32603; | 30 const INTERNAL_ERROR = -32603; |
31 | 31 |
32 /// An unexpected error occurred on the server. | 32 /// An unexpected error occurred on the server. |
33 /// | 33 /// |
34 /// The spec reserves the range from -32000 to -32099 for implementation-defined | 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. | 35 /// server exceptions, but for now we only use one of those values. |
36 const SERVER_ERROR = -32000; | 36 const SERVER_ERROR = -32000; |
37 | |
38 String name(int errorCode) { | |
Bob Nystrom
2014/11/03 18:43:55
Doc comment.
nweiz
2014/11/04 02:22:45
Done.
| |
39 switch (errorCode) { | |
40 case PARSE_ERROR: return "parse error"; | |
41 case INVALID_REQUEST: return "invalid request"; | |
42 case METHOD_NOT_FOUND: return "method not found"; | |
43 case INVALID_PARAMS: return "invalid parameters"; | |
44 case INTERNAL_ERROR: return "internal error"; | |
45 default: return null; | |
Bob Nystrom
2014/11/03 18:43:55
I can see the value in not throwing an ArgumentErr
nweiz
2014/11/04 02:22:45
These error codes are the ones listed in the spec,
Bob Nystrom
2014/11/04 20:28:16
SGTM.
| |
46 } | |
47 } | |
OLD | NEW |