1 | ;
|
2 | /*
|
3 | * Copyright 2019 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 | */
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | exports.StatusBuilder = void 0;
|
20 | /**
|
21 | * A builder for gRPC status objects.
|
22 | */
|
23 | class StatusBuilder {
|
24 | constructor() {
|
25 | this.code = null;
|
26 | this.details = null;
|
27 | this.metadata = null;
|
28 | }
|
29 | /**
|
30 | * Adds a status code to the builder.
|
31 | */
|
32 | withCode(code) {
|
33 | this.code = code;
|
34 | return this;
|
35 | }
|
36 | /**
|
37 | * Adds details to the builder.
|
38 | */
|
39 | withDetails(details) {
|
40 | this.details = details;
|
41 | return this;
|
42 | }
|
43 | /**
|
44 | * Adds metadata to the builder.
|
45 | */
|
46 | withMetadata(metadata) {
|
47 | this.metadata = metadata;
|
48 | return this;
|
49 | }
|
50 | /**
|
51 | * Builds the status object.
|
52 | */
|
53 | build() {
|
54 | const status = {};
|
55 | if (this.code !== null) {
|
56 | status.code = this.code;
|
57 | }
|
58 | if (this.details !== null) {
|
59 | status.details = this.details;
|
60 | }
|
61 | if (this.metadata !== null) {
|
62 | status.metadata = this.metadata;
|
63 | }
|
64 | return status;
|
65 | }
|
66 | }
|
67 | exports.StatusBuilder = StatusBuilder;
|
68 | //# sourceMappingURL=status-builder.js.map |
\ | No newline at end of file |