-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Errors
chris edited this page Jan 30, 2016
·
7 revisions
Errors are returned with the standard Go mechanism. However, if you need to get the details of the error as reported by Elasticsearch, you can do so by "casting" to *elastic.Error
. Here's an example:
_, err := client.IndexExists("twitter").Do()
if err != nil {
// Get *elastic.Error which contains additional information
e, ok := err.(*elastic.Error)
if !ok {
// This shouldn't happen
...
}
log.Printf("Elastic failed with status %d and error %s.", e.Status, e.Details)
...
}