I have a error type like below defined
type RetryableError struct {
msg string
}
func (a *RetryableError) Error() string {
return a.msg
}
In a unit test, what is the Go way of asserting if the error returned is of RetryableError
type?
Use type assertion:
err := someFunc()
if retryable, ok := err.(RetryableError); ok {
// use retryable
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments