fishy commented on a change in pull request #2298:
URL: https://github.com/apache/thrift/pull/2298#discussion_r560297343



##########
File path: lib/go/thrift/exception.go
##########
@@ -26,19 +26,86 @@ import (
 // Generic Thrift exception
 type TException interface {
        error
+
+       TExceptionType() TExceptionType
 }
 
 // Prepends additional information to an error without losing the Thrift 
exception interface
 func PrependError(prepend string, err error) error {
-       if t, ok := err.(TTransportException); ok {
-               return NewTTransportException(t.TypeId(), prepend+t.Error())
+       msg := prepend + err.Error()
+
+       if te, ok := err.(TException); ok {
+               switch te.TExceptionType() {
+               case TExceptionTypeTransport:
+                       if t, ok := err.(TTransportException); ok {
+                               return NewTTransportException(t.TypeId(), msg)
+                       }
+               case TExceptionTypeProtocol:
+                       if t, ok := err.(TProtocolException); ok {
+                               return 
NewTProtocolExceptionWithType(t.TypeId(), errors.New(msg))
+                       }
+               case TExceptionTypeApplication:
+                       if t, ok := err.(TApplicationException); ok {
+                               return NewTApplicationException(t.TypeId(), msg)
+                       }
+               }
+
+               return wrappedTException{
+                       err:            errors.New(msg),

Review comment:
       Oh I think this is the one coming from `THeaderTransport`: 
https://github.com/apache/thrift/blob/7f9abb1cc0f4b2793a48f45ddfcf0d2b287cc50c/lib/go/thrift/header_transport.go#L689,
 as that's the only place in the codebase we return `ctx.Err()` in any way.
   
   So this is actually `TTransportException` wrapped `context.Canceled`, which 
means doing it inside `wrappedTException` won't fix the issue. We need to 
implement that in `tTransportException` as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to