SDK
SDK Golang v3.x
2

Error Handling #

All methods return an "error" struct, which holds a non-nil value if the call failed. Error structs are all of type KuzzleError.

The KuzzleError type implements the standard error interface, and adds the following properties to it:

PropertyTypeDescription
StatusintStatus following HTTP Standards
StackstringError stacktrace (Only in development mode)

You can find a detailed list of possible errors messages and statuses in the documentation API.

Example #

err := kuzzle.Index.Create("nyc-open-data", nil)
if err != nil {
  fmt.Println(err.Error())
  // Type assertion of error to KuzzleError
  if err.(types.KuzzleError).Status == 412 {
    fmt.Println("Try with another name!")
  }
}