fix Contains function for nil arguments (#1102)

Signed-off-by: Ivan Milošević <iva@blokovi.com>
This commit is contained in:
Ivan Milošević 2020-04-07 10:35:38 +02:00 committed by GitHub
parent 382bc89161
commit 338c55e554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -42,12 +42,10 @@ func (ce *customError) Err() Error {
return ce.err return ce.err
} }
// Contains inspects if Error's message is same as error // Contains inspects if e2 error is contained in any layer of e1 error
// in argument. If not it continues further unwrapping
// layers of Error until it founds it or unwrap all layers
func Contains(e1 error, e2 error) bool { func Contains(e1 error, e2 error) bool {
if e1 == nil || e2 == nil { if e1 == nil || e2 == nil {
return e2 == nil return e2 == e1
} }
ce, ok := e1.(Error) ce, ok := e1.(Error)
if ok { if ok {