You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by GitBox <gi...@apache.org> on 2022/08/01 19:49:20 UTC

[GitHub] [thrift] fishy opened a new pull request, #2637: THRIFT-5605: Client middleware to extract exceptions

fishy opened a new pull request, #2637:
URL: https://github.com/apache/thrift/pull/2637

   Client: go
   
   Provide ExtractIDLExceptionClientMiddleware client middleware
   implementation to extract exceptions defined in thrift IDL into err
   return so they are accessible from other client middlewares.
   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [thrift] fishy commented on a diff in pull request #2637: THRIFT-5605: Client middleware to extract exceptions

Posted by GitBox <gi...@apache.org>.
fishy commented on code in PR #2637:
URL: https://github.com/apache/thrift/pull/2637#discussion_r934960128


##########
lib/go/thrift/middleware.go:
##########
@@ -107,3 +110,76 @@ func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
 	}
 	return client
 }
+
+// For a endpoint defined in thrift IDL like this:
+//
+//     service MyService {
+//       FooResponse foo(1: FooRequest request) throws (
+//         1: Exception1 error1,
+//         2: Exception2 error2,
+//       )
+//     }
+//
+// The thrift compiler generated go code for the result TStruct would be like:
+//
+//     type MyServiceFooResult struct {
+//       Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
+//       Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
+//       Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
+//     }
+func getClientError(result TStruct, err error) error {

Review Comment:
   @dcelasun I'm also debating whether to export this as a public API, and if yes, what's a good name for it.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [thrift] dcelasun commented on a diff in pull request #2637: THRIFT-5605: Client middleware to extract exceptions

Posted by GitBox <gi...@apache.org>.
dcelasun commented on code in PR #2637:
URL: https://github.com/apache/thrift/pull/2637#discussion_r935127436


##########
lib/go/thrift/middleware.go:
##########
@@ -107,3 +110,76 @@ func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
 	}
 	return client
 }
+
+// For a endpoint defined in thrift IDL like this:
+//
+//     service MyService {
+//       FooResponse foo(1: FooRequest request) throws (
+//         1: Exception1 error1,
+//         2: Exception2 error2,
+//       )
+//     }
+//
+// The thrift compiler generated go code for the result TStruct would be like:
+//
+//     type MyServiceFooResult struct {
+//       Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
+//       Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
+//       Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
+//     }
+func getClientError(result TStruct, err error) error {

Review Comment:
   I think it's fine to make it public, but maybe move it to `exception.go` and call it `GetClientException`?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [thrift] fishy commented on a diff in pull request #2637: THRIFT-5605: Client middleware to extract exceptions

Posted by GitBox <gi...@apache.org>.
fishy commented on code in PR #2637:
URL: https://github.com/apache/thrift/pull/2637#discussion_r935863659


##########
lib/go/thrift/middleware.go:
##########
@@ -107,3 +110,76 @@ func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
 	}
 	return client
 }
+
+// For a endpoint defined in thrift IDL like this:
+//
+//     service MyService {
+//       FooResponse foo(1: FooRequest request) throws (
+//         1: Exception1 error1,
+//         2: Exception2 error2,
+//       )
+//     }
+//
+// The thrift compiler generated go code for the result TStruct would be like:
+//
+//     type MyServiceFooResult struct {
+//       Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
+//       Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
+//       Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
+//     }
+func getClientError(result TStruct, err error) error {

Review Comment:
   What do you think of `ExtractExceptionFromResult`?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [thrift] fishy merged pull request #2637: THRIFT-5605: Client middleware to extract exceptions

Posted by GitBox <gi...@apache.org>.
fishy merged PR #2637:
URL: https://github.com/apache/thrift/pull/2637


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [thrift] dcelasun commented on a diff in pull request #2637: THRIFT-5605: Client middleware to extract exceptions

Posted by GitBox <gi...@apache.org>.
dcelasun commented on code in PR #2637:
URL: https://github.com/apache/thrift/pull/2637#discussion_r935868152


##########
lib/go/thrift/middleware.go:
##########
@@ -107,3 +110,76 @@ func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
 	}
 	return client
 }
+
+// For a endpoint defined in thrift IDL like this:
+//
+//     service MyService {
+//       FooResponse foo(1: FooRequest request) throws (
+//         1: Exception1 error1,
+//         2: Exception2 error2,
+//       )
+//     }
+//
+// The thrift compiler generated go code for the result TStruct would be like:
+//
+//     type MyServiceFooResult struct {
+//       Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
+//       Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
+//       Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
+//     }
+func getClientError(result TStruct, err error) error {

Review Comment:
   Sounds good!



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org