Modo-me commented on code in PR #3498:
URL: https://github.com/apache/dubbo-go/pull/3498#discussion_r3685717648
##########
protocol/dubbo/hessian2/hessian_response.go:
##########
@@ -34,56 +34,24 @@ import (
perrors "github.com/pkg/errors"
)
-// DubboResponse dubbo response
-type DubboResponse struct {
- RspObj any
- Exception error
- Attachments map[string]any
-}
-
-// GenericException keeps Java exception class and message.
-type GenericException struct {
- ExceptionClass string
- ExceptionMessage string
-}
-
-// Error returns a readable error string.
-func (e GenericException) Error() string {
- if e.ExceptionClass == "" {
- return e.ExceptionMessage
- }
- if e.ExceptionMessage == "" {
- return e.ExceptionClass
- }
- return "java exception: " + e.ExceptionClass + " - " +
e.ExceptionMessage
-}
+// GenericException is a type alias of hessian.GenericException for backward
+// compatibility.
+//
+// Deprecated: Use hessian.GenericException from
github.com/apache/dubbo-go-hessian2 instead.
+type GenericException = hessian.GenericException
// ToGenericException converts decoded exception to GenericException when
possible.
+//
+// Deprecated: Use hessian.ToGenericException from
github.com/apache/dubbo-go-hessian2 instead.
func ToGenericException(expt any) (*GenericException, bool) {
- switch v := expt.(type) {
- case *GenericException:
- return v, true
- case GenericException:
- return &v, true
- case *java_exception.DubboGenericException:
- return &GenericException{ExceptionClass: v.ExceptionClass,
ExceptionMessage: v.ExceptionMessage}, true
- case java_exception.DubboGenericException:
- return &GenericException{ExceptionClass: v.ExceptionClass,
ExceptionMessage: v.ExceptionMessage}, true
- case java_exception.Throwabler:
- return &GenericException{ExceptionClass: v.JavaClassName(),
ExceptionMessage: v.Error()}, true
- case string:
- return parseLegacyException(v), true
- }
- return nil, false
+ return hessian.ToGenericException(expt)
Review Comment:
当前修复已完整保留了dubbo-go内部的原本旧版`ToGenericException()`
`GenericException`实现并标为Deprecated
,保证了旧版在下游的兼容性。而dubbo-go内部其他所有地方对`ToGenericException()`
`GenericException`的引用均已迁移到dubbo-go-hessian2中的新版实现。同时,`generic_exception_compat_test.go`补全了string
分支的断言
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]