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..f510d8bb5541d517e0ebf69d5f81a744179c0a15 100644 |
| --- a/pkg/json_rpc_2/lib/error_code.dart |
| +++ b/pkg/json_rpc_2/lib/error_code.dart |
| @@ -34,3 +34,14 @@ 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; |
| + |
| +String name(int errorCode) { |
|
Bob Nystrom
2014/11/03 18:43:55
Doc comment.
nweiz
2014/11/04 02:22:45
Done.
|
| + 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; |
|
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.
|
| + } |
| +} |