-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize err #395
optimize err #395
Conversation
# Conflicts: # pkg/datasource/sql/exec/executor.go
@@ -41,7 +41,7 @@ func (g *BranchCommitResponseCodec) Decode(in []byte) interface{} { | |||
if data.ResultCode == message.ResultCodeFailed { | |||
data.Msg = bytes.ReadString8Length(buf) | |||
} | |||
data.TransactionErrorCode = serror.TransactionErrorCode(bytes.ReadByte(buf)) | |||
data.TransactionErrorCode = serror.ErrorCode(bytes.ReadByte(buf)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不用改哈,TransactionErrorCode 可以提现这个error的类型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是因为transactionErr合并到了seataError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是因为transactionErr合并到了seataError
这里为啥要合并呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TransactionErrorCode 建议保留,和java那边对应上,会更好理解,感觉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯这里改回来了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里也是因为transactionErr合并到了seataError
这里为啥要合并呢?
因为err比较乱,在不同的包里定义可能后期会出现循环引用?
pkg/rm/tcc/fence/fence_api_test.go
Outdated
@@ -51,8 +51,8 @@ func TestWithFence(t *testing.T) { | |||
return nil | |||
}, | |||
wantErr: true, | |||
errStr: errors.NewTccFenceError( | |||
errors.FencePhaseError, | |||
errStr: errors.New( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.New 会出问题吗?后文是否会用这个error类型做判断?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的errors是项目里定义的error包,支持后面判断的
@@ -73,14 +73,14 @@ func (handler *tccFenceWrapperHandler) PrepareFence(ctx context.Context, tx *sql | |||
|
|||
err := handler.insertTCCFenceLog(tx, xid, branchId, actionName, enum.StatusTried) | |||
if err != nil { | |||
dbError, ok := err.(seataErrors.TccFenceError) | |||
if ok && dbError.Code == seataErrors.TccFenceDbDuplicateKeyError { | |||
dbError, ok := err.(seataErrors.SeataError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个类型要改吗?TccFenceError 看起来是有明确含义的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TccFenceError+transactionErr合并到了seataError;后面会再通过errcode确定err含义
合并前,transactionErr仅有一个判断,也合并到了seataError的逻辑
Codecov Report
@@ Coverage Diff @@
## master #395 +/- ##
==========================================
- Coverage 40.67% 40.60% -0.07%
==========================================
Files 139 138 -1
Lines 8732 8737 +5
==========================================
- Hits 3552 3548 -4
- Misses 4891 4900 +9
Partials 289 289
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
还有就是,现在errors包有俩,一个go自带的,一个是 |
Also, now there are two errors packages, one comes with go, and the other is |
pkg/datasource/sql/undo/builder/mysql_update_undo_log_builder_test.go
Outdated
Show resolved
Hide resolved
type TccFenceError struct { | ||
Code TransactionErrorCode | ||
type SeataError struct { | ||
Code ErrorCode | ||
Message string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想,这个error意义并不是很大,要不去掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前不去掉的原因是
- 这个error保存了parentError信息,但是没有用到parentError的地方,这一点移除没影响
- 再一点就是这个err会保存一些上下文,但是也没有基于上下文对error的一些判断
所以或许可以移除?
# Conflicts: # pkg/remoting/getty/getty_client_test.go # pkg/remoting/getty/rpc_client.go
optimize error
optimize error
What this PR does:
fmt.Errorf
witherrors.New
/pkg/datasource/sql/types/error
intopkg/util/errors/
Which issue(s) this PR fixes:
Fixes #379
Special notes for your reviewer:
Does this PR introduce a user-facing change?: