Skip to content

Commit 381123e

Browse files
authored
Call VerifySuccess before return to user (#151) (#157)
* Move VerifySuccess * fix missing code * fix missing code * fix copilot review
1 parent 7718561 commit 381123e

File tree

6 files changed

+211
-144
lines changed

6 files changed

+211
-144
lines changed

client/errors.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,34 @@
2020
package client
2121

2222
import (
23-
"bytes"
23+
"fmt"
24+
2425
"github.com/apache/iotdb-client-go/common"
2526
)
2627

28+
// ExecutionError represents an error returned by the server via TSStatus.
29+
// It is NOT a connection error and should not cause session drops.
30+
type ExecutionError struct {
31+
Code int32
32+
Message string
33+
}
34+
35+
func (e *ExecutionError) Error() string {
36+
if e.Message != "" {
37+
return fmt.Sprintf("error code: %d, message: %v", e.Code, e.Message)
38+
}
39+
return fmt.Sprintf("error code: %d", e.Code)
40+
}
41+
2742
type BatchError struct {
2843
statuses []*common.TSStatus
44+
Message string
2945
}
3046

3147
func (e *BatchError) Error() string {
32-
buff := bytes.Buffer{}
33-
for _, status := range e.statuses {
34-
buff.WriteString(*status.Message + ";")
35-
}
36-
return buff.String()
48+
return e.Message
3749
}
3850

3951
func (e *BatchError) GetStatuses() []*common.TSStatus {
4052
return e.statuses
4153
}
42-
43-
func NewBatchError(statuses []*common.TSStatus) *BatchError {
44-
return &BatchError{
45-
statuses: statuses,
46-
}
47-
}

0 commit comments

Comments
 (0)