Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a StructLike class that extends Error.
Exception classes should extend this so that they derive from Error. As mentioned in [the GitHub issue](creditkarma/thrift-typescript#178), this is useful because it causes Thrift exceptions to have stack traces and because some frameworks expect exceptions to derive from Error. The GitHub issue mentions graphql-js. Jest's `toThrow()` function would also benefit from this. Here's an example: ``` await expect(thriftClient.someFunction()).rejects.toThrow() ``` `toThrow` doesn't identify Thrift exceptions as exceptions because they don't derive from Error and so it will return false in such cases. Part of the blame could fall on Jest, because perhaps `toThrow` should return true for any rejected promise regardless of the type of object being throw, but I think some of the blame still falls on Thrift. Possible remaining work: - Add a test? - Bump version number so end users can require the new version.
- Loading branch information