UNPKG

1.58 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2022 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.restrictControlPlaneStatusCode = void 0;
20const constants_1 = require("./constants");
21const INAPPROPRIATE_CONTROL_PLANE_CODES = [
22 constants_1.Status.OK,
23 constants_1.Status.INVALID_ARGUMENT,
24 constants_1.Status.NOT_FOUND,
25 constants_1.Status.ALREADY_EXISTS,
26 constants_1.Status.FAILED_PRECONDITION,
27 constants_1.Status.ABORTED,
28 constants_1.Status.OUT_OF_RANGE,
29 constants_1.Status.DATA_LOSS
30];
31function restrictControlPlaneStatusCode(code, details) {
32 if (INAPPROPRIATE_CONTROL_PLANE_CODES.includes(code)) {
33 return {
34 code: constants_1.Status.INTERNAL,
35 details: `Invalid status from control plane: ${code} ${constants_1.Status[code]} ${details}`
36 };
37 }
38 else {
39 return { code, details };
40 }
41}
42exports.restrictControlPlaneStatusCode = restrictControlPlaneStatusCode;
43//# sourceMappingURL=control-plane-status.js.map
\No newline at end of file