3 ms·
Error is an interface. The default one may be a string but you can implement your open error with whatever extras you would like.
by donatj 7y ago
Error is an interface. The default one may be a string but you can implement your open error with whatever extras you would like.
- CameronNemo 7y agoRight but then you need to use errors.as to match against it, rather than being able to do pattern matching. And there is no inheritance, no ability to generalize errors into a group.
- donatj 7y agoYou can totally just type assert your custom error type to check for it. If it's the only type of error your method returns you don't even need to, just define your return type as your custom error type.