kaspad/testutil/testutil.go
Ori Newman a7f08598f3 [NOD-416] Use errors.Is and add goroutine stack trace to HandlePanic (#459)
* [NOD-416] Use errors.Is and add goroutine stack trace to HandlePanic

* [NOD-416] Don't print goroutineStackTrace if it's nil
2019-11-13 11:20:20 +02:00

21 lines
397 B
Go

package testutil
import (
"fmt"
)
// AreErrorsEqual returns whether errors have the same type
// and same error string from .Error().
func AreErrorsEqual(err1, err2 error) bool {
if err1 == nil && err2 == nil {
return true
}
if err1 == nil && err2 != nil {
return false
}
if fmt.Sprintf("%T", err1) != fmt.Sprintf("%T", err2) {
return false
}
return err1.Error() == err2.Error()
}