3 ms·
> parsing error results inside strings I don't know why this is a thing. I create an explicit type for errors that I know I'm going to do something with, and d
by marcus_holmes 7y ago
> parsing error results inside strings
I don't know why this is a thing. I create an explicit type for errors that I know I'm going to do something with, and do type assertions to check for them. I believe this was the intention behind the design in the first place.
- grey-area 7y agoBecause many libraries (including stdlib) return basic errors which you can do nothing else with. I think that's the main problem with this design - you're reliant on others to produce errors you can reliably check against, and every library could potentially have its own error types (similar to the problems with a proliferation of exception types in languages using exceptions). When using your own libraries it is not a huge problem - as you say you can start using a more complex type. Not sure what the answer is, but the error interface which only allows returning a string is partly to blame IMO.