Index: server/static/rpc/rpc-code.html |
diff --git a/server/static/rpc/rpc-code.html b/server/static/rpc/rpc-code.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bdc0218c6c5dca21c353c7c0ea890758cc3c8292 |
--- /dev/null |
+++ b/server/static/rpc/rpc-code.html |
@@ -0,0 +1,53 @@ |
+<!-- |
+ Copyright 2016 The Chromium Authors. All rights reserved. |
+ Use of this source code is governed by a BSD-style license that can be |
+ found in the LICENSE file. |
+ --> |
+ |
+<script> |
+ 'use strict'; |
+ |
+ var luci = (function(luci) { |
+ |
+ var rpc = luci.rpc = luci.rpc || {}; |
+ |
+ /** |
+ * gRPC response codes. |
+ * based on https://github.com/grpc/grpc-go/blob/972dbd2/codes/codes.go#L43 |
+ * @enum {number} |
+ */ |
+ rpc.Code = { |
+ OK: 0, |
+ CANCELED: 1, |
+ UNKNOWN: 2, |
+ INVALID_ARGUMENT: 3, |
+ DEADLINE_EXCEEDED: 4, |
+ NOT_FOUND: 5, |
+ ALREADY_EXISTS: 6, |
+ PERMISSION_DENIED: 7, |
+ UNAUTHENTICATED: 16, |
+ RESOURCE_EXHAUSTED: 8, |
+ FAILED_PRECONDITION: 9, |
+ ABORTED: 10, |
+ OUT_OF_RANGE: 11, |
+ UNIMPLEMENTED: 12, |
+ INTERNAL: 13, |
+ UNAVAILABLE: 14, |
+ DATA_LOSS: 15 |
+ }; |
+ |
+ var codeNames = {}; |
+ for (var name in rpc.Code) { |
+ codeNames[rpc.Code[name]] = name; |
+ } |
+ |
+ /** |
+ * Returns response code name or undefined. |
+ */ |
+ rpc.CodeName = function(code) { |
+ return codeNames[code]; |
+ }; |
+ |
+ return luci; |
+ }(luci || {})); |
+</script> |