mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 14:46:44 +00:00

* [NOD-416] Use errors.Is and add goroutine stack trace to HandlePanic * [NOD-416] Don't print goroutineStackTrace if it's nil
21 lines
397 B
Go
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()
|
|
}
|