by ainar-g · 8y ago · 0 comments
switch {
case transfer == nil:
return nil, ErrInvalidTransfer
case person == nil:
return nil, ErrInvalidPerson
// ...
}
This, to me, is both concise and clear.I can see the appeal of wanting to create a package to manage error checking when you have dozens of conditions but this doesn't bring anything new to the table yet creates code that is arguably less maintainable and certainly less easily read.