[
https://issues.apache.org/jira/browse/THRIFT-2403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13938819#comment-13938819
]
Jake Farrell commented on THRIFT-2403:
--------------------------------------
Hey [~ryangreenberg], makes complete sense and happy to review if you have a
patch
> Differentiate various TransportExceptions as separate classes
> -------------------------------------------------------------
>
> Key: THRIFT-2403
> URL: https://issues.apache.org/jira/browse/THRIFT-2403
> Project: Thrift
> Issue Type: Improvement
> Components: Ruby - Library
> Reporter: Ryan Greenberg
>
> The Ruby thrift library raises Thrift::TransportException of three different
> types (NOT_OPEN, TIMED_OUT, UNKNOWN), which client libraries may want to
> handle in different ways. Since rescuing in Ruby is specified by exception
> class, providing different behavior for the different types requires rescuing
> all transport exceptions and checking the type.
> Would the project consider introducing separate subclasses of
> Thrift::TransportException for the current types? Specifically:
> {code}
> class Thrift::TransportException::NotOpen < Thrift::TransportException
> class Thrift::TransportException::TimedOut < Thrift::TransportException
> class Thrift::TransportException::Unknown < Thrift::TransportException
> {code}
> This change would allow you to rewrite this code:
> {code}
> begin
> ...
> rescue Thrift::TransportException => ex
> if ex.type == Thrift::TransportException::NOT_OPEN
> ...
> else
> raise ex
> end
> end
> {code}
> as:
> {code}
> begin
> ...
> rescue Thrift::TransportException::NotOpen
> ...
> end
> {code}
> Backwards compatibility could be maintained by continuing to provide the type
> via the {{.type}} method, and by having Thrift::TransportException::NotOpen
> et. al. subclass Thrift::TransportException.
> See https://github.com/twitter/thrift_client/issues/56 for additional
> background.
--
This message was sent by Atlassian JIRA
(v6.2#6252)