Closed elliotchance closed 6 years ago
In Golang errors are values, more comfortable to provide error with a particular message and type, and check them
What do you mean by error type?
type MyError struct {
Err error
}
func (e MyError) Error() string {
return err.Error()
}
customErr := MyError{
Err: errors.New("i am an error wrapper")
}
r := tf.Function(t, ReturnError() error {
return customError
})
// This wil pass
r().Errors("i am an error wrapper")
r().Errors(customError)
r().Errors()
// This will fail
r().Errors(errors.New("i am an error wrapper"))
Ah yes, I understand what you mean now. I agree.
Currently on it, but it's harder than i think. Need to have some refactoring to make works properly.
@elliotchance this one solved by #12
Thanks Pavel.
Based on the fact many functions return
result, error
it can test for the existence of an error or even further with a message: