Is there a way of adding type hierarchy information to generated thrift exception types for Java.
I want to define some common set of exceptions, that people can reuse. It often happens that clients instead of handling individual exceptions, want to handle a group of exceptions. For example, lets say a java client wants to catch all bad requests and print the exception message. The client does not want to handle the individual exceptions like TooBigParamException, MissingParamException etc, but instead just wants to catch a parent of these: BadRequestException. Is there a way to to change the generated codes of TooBigParamException, MissingParamException etc to add an extends relationship?
I tried Facebook swift (Java -> Thrift conversion), but it looks like it does not work seamlessly with Apache thrift.
I found one decent solution. Though I would not say that there are no hacks in that.
When I began, there were only 2 options with me:
I was able to workaround these problems, by combining the above 2. I first wrote the java exceptions and then generated IDL using swift. Then generated another version of java exceptions from idl. I used modelmapper to convert between my original java types and generated java types. My service-core uses the first version of exceptions and my service -thrift layer, converts them to their thrift version using modelmapper.