Compile a list of error handling in go client
wenhaocs opened this issue · 2 comments
wenhaocs commented
Compile a list of error handling in go client
Aiee commented
Nebula GO Error Code Gudie
ResultSet
is a wrapper of ExecutionResponse
, and ExecutionResponse
contains the error code returned from the Nebula service.
type ResultSet struct {
resp *graph.ExecutionResponse
columnNames []string
colNameIndexMap map[string]int
timezoneInfo timezoneInfo
}
type ExecutionResponse struct {
ErrorCode nebula0.ErrorCode
LatencyInUs int64
Data *nebula0.DataSet
SpaceName []byte
ErrorMsg []byte
PlanDesc *PlanDescription
Comment []byte
}
In most cases, an error code will be returned with an error message to the user.
// Execute a query and handle the error
resultSet, err := session.Execute(createSchema)
if err != nil {
fmt.Print(err.Error())
return
}
some common error codes from the Nebula service:
- ErrorCode_SUCCEEDED
- The query is executed successfully
- ErrorCode_E_BAD_USERNAME_PASSWORD
- check user credentials
- ErrorCode_E_SESSION_INVALID
- session expired, get a new session
- ErrorCode_E_SESSION_TIMEOUT
- session is timeout, get a new session
- ErrorCode_E_SYNTAX_ERROR
- syntax error in the query, check the query
- ErrorCode_E_EXECUTION_ERROR
- runtime error occurs when executing the query, check the error message for details
- ErrorCode_E_USER_NOT_FOUND
- the user does not exist
- ErrorCode_E_BAD_PERMISSION
- current user has no permission to execute the query(i.g.
KILL SESSIONS
)
- current user has no permission to execute the query(i.g.
- ErrorCode_E_SEMANTIC_ERROR
- semantic error in the query, check the query
- ErrorCode_E_LEADER_CHANGE
- retry
wenhaocs commented
If one graphd instance is down due to maintenance or unexpected error, refer to the following logic to retry and reconnect to other graphd. https://github.com/vesoft-inc/nebula-go/blob/master/session.go#L39-L45
err2, ok := err.(thrift.TransportException)
if !ok {
return err
}
if err2.TypeID() != thrift.END_OF_FILE {
return err
}