Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Commit d98d5f2

Browse files
authored
Re-export ServiceError from grpc-js (#127)
The callback passed to API calls can return an instance of `ServiceError`, a type from grpc-js. The type is mentioned in the documentation and the tutorial, but wasn't re-exported in the SDK. This has been fixed.
1 parent a0514bf commit d98d5f2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

examples/typescript/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import {
33
AtcServiceClient,
44
GetVersionRequest,
55
GetVersionResponse,
6+
ServiceError,
67
} from "auto-traffic-control";
78

89
const atcService = new AtcServiceClient("localhost:4747", getCredentials());
910

1011
atcService.getVersion(
1112
new GetVersionRequest(),
12-
(err, response: GetVersionResponse) => {
13+
(err: ServiceError | null, response: GetVersionResponse) => {
1314
if (err != null) {
1415
throw err;
1516
}

sdk/node/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { credentials, ChannelCredentials } from "@grpc/grpc-js";
1+
import { credentials, ChannelCredentials, ServiceError } from "@grpc/grpc-js";
22

33
export * from "./atc/v1/airplane_pb";
44
export * from "./atc/v1/airplane_grpc_pb";
@@ -12,6 +12,8 @@ export * from "./atc/v1/map_pb";
1212
export * from "./atc/v1/map_grpc_pb";
1313
export * from "./atc/v1/tag_pb";
1414

15+
export { ChannelCredentials, ServiceError };
16+
1517
export function getCredentials(): ChannelCredentials {
1618
return credentials.createInsecure();
1719
}

0 commit comments

Comments
 (0)