creditkarma/thrift-typescript

No way to distinguish exception objects

Opened this issue · 1 comments

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.

#178 is related.