ts-proto
ts-proto copied to clipboard
Export better Error type for grpc-web
See the output file here: https://github.com/stephenh/ts-proto/blob/e4351d4304be2d2ce7b95e74e2c5f2383d6754e5/integration/grpc-web/example.ts#L847-L850
It sets code
and metadata
into the Error object, but it would be great to export a better type for the Error object, so consumers can use the Error object more safely.
Right now we have to do something like this:
try {
return await client.method({ url });
} catch (e) {
if (e instanceof Error) {
const grpcCode = "code" in e ? (e["code"] as number) : "unknown";
console.log("grpcCode", grpcCode);
}
}
@zlk89 makes sense! If you want to submit a PR, that'd be great.
This is fixed by #593