Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make error clearer when assigning non-string to string field
Summary: Context == When working with some "convert this object to a Thrift object" code, a mistake in the source object was sending what should be a string field as an integer. The only error raised was ``` 1) TypeError: bad argument type for built-in operation File "thrift.python/types.pyx", line 616, in thrift.python.types.Struct.__init__ File "thrift.python/types.pyx", line 130, in thrift.python.types.StringTypeInfo.to_internal_data ``` This error is about as helpful as a chocolate teapot on an open fire, to me. This change catches the TypeError that's raised by the UTF8String call, and reframes it with context that might help an end user understand precisely what has happened. It would be even better if it would indicate which field is deemed a string in the Thrift spec, and is being passed as not-string to the code, but I don't know how to get at that data in this file. Implementation == * Catch and re-raise TypeError with context details * Add a unit test that validates the re-raise message Reviewed By: aristidisp Differential Revision: D53225702 fbshipit-source-id: e926d5af4eabee61f7548460c87843204b963c6e
- Loading branch information