[ https://issues.apache.org/jira/browse/THRIFT-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13679006#comment-13679006 ]
Randy Abernethy commented on THRIFT-237: ---------------------------------------- Hello Jens, I think you have it right. The goal is to have all Thrift language libraries implement a class called TException from which all other Thrift exceptions are derived. In general TException itself should be derived from the appropriate language specific built in exception class (if any). This is how things are organized in C++, Java and Python for example. C# does not have a TException, so TTransportException derives from System.Exception (a .net exception). As noted, the problem with this approach is that if you want to catch all Apache Thrift exceptions, you must list them out one by one in C#. If someone adds an exception you will be out of luck. In C++ the hierarchy looks like: std::exception apache::thrift::TException apache::thrift::transport::TTransportException apache::thrift::protocol::TProtocolException apache::thrift::TApplicationException user defined exceptions in IDL Java is similar: java.lang.Throwable java.lang.Exception org.apache.thrift.TException etc. Python: BaseException Exception thrift.Thrift.TException etc. Best, Randy > Update Exception class generation to TException decendent > --------------------------------------------------------- > > Key: THRIFT-237 > URL: https://issues.apache.org/jira/browse/THRIFT-237 > Project: Thrift > Issue Type: Improvement > Components: C# - Compiler, Cocoa - Compiler, Java - Compiler, Python > - Compiler > Environment: Java > Reporter: Martin Smith > Priority: Trivial > Original Estimate: 4h > Remaining Estimate: 4h > > Make all generated Exception objects derived classes of TExceptions instead > of Exceptions. This allows callers to handle all errors of their service by > catching TException, eliminating the need for multiple catch blocks where not > required by the client code. > This follows the more recent patterns set for C++, PHP, Perl. > The languages affects are > Java, python, Cocoa, csharp > This could negatively affect code where the base exception class TException > is handled prior to the generated exception classes. > e.g. > try { > } catch (TException te) { > } catch (ThriftAppException tae) { > } > Patch available for Java, can build patches for python, cocoa and csharp at > the same time. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira