fix Contains function for nil arguments (#1102)
Signed-off-by: Ivan Milošević <iva@blokovi.com>
This commit is contained in:
parent
382bc89161
commit
338c55e554
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue