Skip to content

Commit

Permalink
Make ServiceError optionally null (#116)
Browse files Browse the repository at this point in the history
* Make ServiceError optionally null

* Unwrap optional error in tests
  • Loading branch information
colinking authored and jonnyreeves committed Sep 24, 2018
1 parent 67e0c93 commit 8ca48fe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/generated/proto/orphan_pb_service.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/service/grpcweb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,11 @@ function printUnaryStubMethodTypes(printer: CodePrinter, method: RPCMethodDescri
.printLn(`${method.nameAsCamelCase}(`)
.indent().printLn(`requestMessage: ${method.requestType},`)
.printLn(`metadata: grpc.Metadata,`)
.printLn(`callback: (error: ServiceError, responseMessage: ${method.responseType}|null) => void`)
.printLn(`callback: (error: ServiceError|null, responseMessage: ${method.responseType}|null) => void`)
.dedent().printLn(`): void;`)
.printLn(`${method.nameAsCamelCase}(`)
.indent().printLn(`requestMessage: ${method.requestType},`)
.printLn(`callback: (error: ServiceError, responseMessage: ${method.responseType}|null) => void`)
.printLn(`callback: (error: ServiceError|null, responseMessage: ${method.responseType}|null) => void`)
.dedent().printLn(`): void;`);
}

Expand Down
6 changes: 3 additions & 3 deletions test/integration/service/grpcweb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ describe("service/grpc-web", () => {
assert.ok(error !== null && typeof error === "object", "should yield an error");
assert.ok(response === null, "should yield null instead of a response");

assert.equal(error.message, "some internal error", "should expose the grpc error message (.message)");
assert.equal(error.code, 13, "should expose the grpc status code (.code)");
assert.ok(error.metadata instanceof grpc.Metadata, "should expose the trailing response metadata (.metadata)");
assert.equal(error!.message, "some internal error", "should expose the grpc error message (.message)");
assert.equal(error!.code, 13, "should expose the grpc status code (.code)");
assert.ok(error!.metadata instanceof grpc.Metadata, "should expose the trailing response metadata (.metadata)");
done();
});
});
Expand Down

0 comments on commit 8ca48fe

Please sign in to comment.