thrift-typescript
thrift-typescript copied to clipboard
No way to distinguish exception objects
I have a service that can throw two different exceptions:
service Whatever {
exception ExceptionA {}
exception ExceptionB {}
void doSomething() throws (1: ExceptionA exceptionA, 2: ExceptionB exceptionB)
}
When the server throws one of the exceptions there's no way for the client to determine which exception was thrown. e.constructor.name is simply "Object"
I'm running thrift-typescript with --target thrift-server.
One workaround is to run thrift-typescript --withNameField, in which case exceptions can be distinguished by checking if (e.__name === 'ExceptionA'), but that's not ideal.
https://github.com/creditkarma/thrift-typescript/issues/178 is related.
I posted a PR that addresses this by changing the client to return instances of our classes.