Usability: Cannot compare to elastigo.RecordNotFound on not found error in CoreGet
untoldone opened this issue · 2 comments
Not sure where this happens/ couldn't easily track down where an the error is created but it seems to be a different object from elastigo.RecordNotFound. As a result, the following code doesn't work:
result, err := conn.Get("source", source, id, nil)
if err == elastigo.RecordNotFound {
...
} else if err != nil {
...
}
Instead, I had to do something like
result, err := conn.Get("source", source, id, nil)
if err != nil && err.Error() == elastigo.RecordNotFound.Error() {
...
} else if err != nil {
...
}
Would be more consistent with standard libs in Go if the first example worked.
hi @untoldone - I agree it would be nice if this could work, however it looks like what you are doing is comparing the error object returned from a different library (where does conn.Get come from?) with the 'wrapped' error type from elastigo. I don't think this can ever work other than the solution you outlined.
can you post the entire source of your example?
My mistake here.
conn
was supposed to be an elastigo.Conn
struct. I had my own branch of elastigo that I forgot to swap back once you accepted another pull request that caused this issue.
This works when you don't mix libraries.