Chromium Code Reviews| Index: pkg/json_rpc_2/lib/error_code.dart |
| diff --git a/pkg/json_rpc_2/lib/error_code.dart b/pkg/json_rpc_2/lib/error_code.dart |
| index 96cb909a314c1b43460526939be225fef554c672..a9be638be678347ca749fa5e416538375c005f5d 100644 |
| --- a/pkg/json_rpc_2/lib/error_code.dart |
| +++ b/pkg/json_rpc_2/lib/error_code.dart |
| @@ -34,3 +34,18 @@ const INTERNAL_ERROR = -32603; |
| /// The spec reserves the range from -32000 to -32099 for implementation-defined |
| /// server exceptions, but for now we only use one of those values. |
| const SERVER_ERROR = -32000; |
| + |
| +/// Returns a human-readable name for [errorCode] if it's one specified by the |
| +/// JSON-RPC 2.0 spec. |
| +/// |
| +/// If [errorCode] isn't specified, returns null. |
|
Bob Nystrom
2014/11/04 20:28:16
"specified" is a bit ambiguous here. The reader co
nweiz
2014/11/05 23:23:39
Done.
|
| +String name(int errorCode) { |
| + switch (errorCode) { |
| + case PARSE_ERROR: return "parse error"; |
| + case INVALID_REQUEST: return "invalid request"; |
| + case METHOD_NOT_FOUND: return "method not found"; |
| + case INVALID_PARAMS: return "invalid parameters"; |
| + case INTERNAL_ERROR: return "internal error"; |
| + default: return null; |
| + } |
| +} |