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

ASF GitHub Bot commented on THRIFT-2854:
----------------------------------------

GitHub user cvlchinet opened a pull request:

    https://github.com/apache/thrift/pull/291

    THRIFT-2854 Go Struct writer and reader looses important error information

    This PR fixes https://issues.apache.org/jira/browse/THRIFT-2854.
    The included test will cover the complete client error handling code except 
the check for the Sequence ID. (unless I miss something)
    I will submit a follow up PR to test the error handling for the Sequence ID 
too once this PR has been merged.
    The covered code makes up the majority of the server error handling code 
too.
    
    And yes.. it was not fun too code the test.. :P

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cvlchinet/thrift go-struct-error

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/291.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #291
    
----
commit 18d2d2b58a1dd3ed256fe189bc9b8a5a77f5bcc5
Author: Chi Vinh Le <c...@chinet.info>
Date:   2014-11-26T23:19:17Z

    Fixes error reporting in go generator

----


> Go Struct writer and reader looses important error information
> --------------------------------------------------------------
>
>                 Key: THRIFT-2854
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2854
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>    Affects Versions: 0.9.2
>            Reporter: Chi Vinh Le
>             Fix For: 0.9.3
>
>
> The GO Compiler generates code for a struct so that the following occurs:
> When an error occurs while reading or writing, a new error is created with 
> additional text information using {code}fmt.Errorf{code}.
> By doing this the original error is completely lost. This is a real problem 
> because errors of type TTransportException and TProtocolExceptions which 
> contain additional information are lost. This will cause bad error handling, 
> as the server implementation is dependent on those information.
> In my personal fork, I have a quick'n dirty fix for this, but I'm looking for 
> a better option.
> Maybe instead of {code}fmt.Errorf{code} we could use this:
> {code}
> // Prepends additional information to an error without losing the Thrift 
> interface
> func PrependError(err error, prepend string) error {
>   if t, ok := err.(TTransportException); ok {
>     return NewTTransportException(t.TypeId(), prepend+t.Error())
>   }
>   if t, ok := err.(TProtocolException); ok {
>     return NewTProtocolExceptionWithType(t.TypeId(), 
> errors.New(prepend+err.Error()))
>   }
>   if t, ok := err.(TApplicationException); ok {
>     return NewTApplicationException(t.TypeId(), prepend+t.Error())
>   }
>   return errors.New(prepend + err.Error())
> }
> {code}
> I want to discuss this first here, because making a patch is quiet some work 
> and I don't want major changes after I create a fix.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to