1

I've got this code

frag, err := bucket.LookupIn(req.Key).Get(req.Path).Execute()
if err != nil {
    res.Code = 1
    res.What = err.Error()
} else {
    frag.Content(req.Path, &res.Data)
}

If I'm trying to request some path which does not exist in the document, I'm getting the error message "could not execute one or more multi lookups or mutations", which also seems to occur on certain different circumstances. How can I distinguish missing data on path from all other kinds of subdoc errors? I'd like to have something like this:

frag, err := bucket.LookupIn(req.Key).Get(req.Path).Execute()
if err != nil {
    if <no data> {
        res.Code = 2
        res.What = "No data on specified path"
    } else {
        res.Code = 1
        res.What = err.Error()
    }
} else {
    frag.Content(req.Path, &res.Data)
}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Denis Sheremet
  • 2,453
  • 2
  • 18
  • 34

1 Answers1

0

You should be able to compare the error values you get back against the list of known error types you can find here: https://godoc.org/github.com/couchbase/gocb#pkg-variables

Brett L
  • 124
  • 2
  • 5
  • It seems there should be `ErrSubDocPathNotFound` error, but I'm getting `ErrSubDocBadMulti` instead, which does not make sence. – Denis Sheremet Mar 12 '18 at 05:18