You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jake Farrell (JIRA)" <ji...@apache.org> on 2014/02/03 18:26:09 UTC

[jira] [Commented] (THRIFT-2343) Golang - Return a single error for all exceptions instead of multiple return values

    [ https://issues.apache.org/jira/browse/THRIFT-2343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13889652#comment-13889652 ] 

Jake Farrell commented on THRIFT-2343:
--------------------------------------

Adding [~jensg] in for review on this as well

> Golang - Return a single error for all exceptions instead of multiple return values
> -----------------------------------------------------------------------------------
>
>                 Key: THRIFT-2343
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2343
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Go - Compiler
>    Affects Versions: 0.9.1
>            Reporter: Chris Bannister
>             Fix For: 0.9.2
>
>         Attachments: 0001-Only-expose-returning-a-single-error-return-in-Go.patch, 0002-go-processor-exceptions-are-treated-as-one-error.patch
>
>
> Currently the Thrift compiler for Go generates some very ugly (by Go's standard) code for method calls. This is because of the fact that Go does not have exceptions.
> My proposal is to change the way the exceptions are handled in Go, instead of returning each exception explicitly as a return value, instead return the exceptions as a single error return. This has another benefit that
> Go servers will no longer be able to 'throw' multiple exceptions, previously
> you could assign an error to all the defined exceptions of a method which
> shouldn't be possible.
> This change relies on the fact that the exceptions generated by Thrift implement the Error interface, which they now do (in 0.9.2).
> It has the downside that the exceptions thrown to a client calling a thrift method are no longer immediately visible. But this is the same way the Go standard library handles it so it shouldn't be a problem.
> It changes the generated interface so it will break backwards compatibility, but as 0.9.2 is already breaking backwards compatibility this shouldn't be a huge problem, but should be considered.
> The proposed changes change the Processor methods for each method, doing a type switch against all the defined exceptions for the method. The fallthrough case is the same INTERNAL_SERVER_ERROR exception.
> Please consider this a RFC.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)