Skip to content

Commit

Permalink
Fix sql error conversion (#4194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaddoll committed May 12, 2021
1 parent 54d2653 commit d893a9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 2 additions & 6 deletions common/persistence/sql/sqlExecutionManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,7 @@ func (m *sqlExecutionManager) updateWorkflowExecutionTx(
newWorkflow.ExecutionInfo.CloseStatus,
startVersion,
lastWriteVersion); err != nil {
return &types.InternalServiceError{
Message: fmt.Sprintf("UpdateWorkflowExecution: failed to continue as new current execution. Error: %v", err),
}
return err
}
} else {
startVersion := updateWorkflow.StartVersion
Expand All @@ -462,9 +460,7 @@ func (m *sqlExecutionManager) updateWorkflowExecutionTx(
executionInfo.CloseStatus,
startVersion,
lastWriteVersion); err != nil {
return &types.InternalServiceError{
Message: fmt.Sprintf("UpdateWorkflowExecution: failed to update current execution. Error: %v", err),
}
return err
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/persistence/sql/sqlExecutionManagerUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ func createTimerTasks(

if int(rowsAffected) != len(timerTasks) {
return &types.InternalServiceError{
Message: fmt.Sprintf("createTimerTasks failed. Inserted %v instead of %v rows into timer_tasks. Error: %v", rowsAffected, len(timerTasks), err),
Message: fmt.Sprintf("createTimerTasks failed. Inserted %v instead of %v rows into timer_tasks.", rowsAffected, len(timerTasks)),
}
}

Expand Down
9 changes: 9 additions & 0 deletions common/persistence/sql/sqlHistoryManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ func (m *sqlHistoryV2Manager) ReadHistoryBranch(
if err == sql.ErrNoRows || (err == nil && len(rows) == 0) {
return &p.InternalReadHistoryBranchResponse{}, nil
}
if err != nil {
return nil, convertCommonErrors(m.db, "ReadHistoryBranch", "", err)
}

history := make([]*p.DataBlob, 0, int(request.PageSize))
eventBlob := &p.DataBlob{}
Expand Down Expand Up @@ -467,6 +470,9 @@ func (m *sqlHistoryV2Manager) GetAllHistoryTreeBranches(
if err == sql.ErrNoRows || (err == nil && len(rows) == 0) {
return &p.GetAllHistoryTreeBranchesResponse{}, nil
}
if err != nil {
return nil, convertCommonErrors(m.db, "GetAllHistoryTreeBranches", "", err)
}
resp := &p.GetAllHistoryTreeBranchesResponse{}
resp.Branches = make([]p.HistoryBranchDetail, len(rows))
for i, row := range rows {
Expand Down Expand Up @@ -508,6 +514,9 @@ func (m *sqlHistoryV2Manager) GetHistoryTree(
if err == sql.ErrNoRows || (err == nil && len(rows) == 0) {
return &p.InternalGetHistoryTreeResponse{}, nil
}
if err != nil {
return nil, convertCommonErrors(m.db, "GetHistoryTree", "", err)
}
for _, row := range rows {
treeInfo, err := m.parser.HistoryTreeInfoFromBlob(row.Data, row.DataEncoding)
if err != nil {
Expand Down

0 comments on commit d893a9c

Please sign in to comment.