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:

Property Type Description
Status int Status following HTTP Standards
Stack string Error stacktrace (Only in development mode)

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


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