by carsongross · 11y ago · 0 comments
- You don't need to define a constructor to take the error string
- You don't need to implement method dispatch (all methods of an error state instance automatically throw, like null does)
Enums are close, but not quite right.
You might, for convenience, have a single method that turns a Connection to a ValidConnection, or else throws, and you can encode your error messages in one place in this method.
I think this proposal permits such a thing, although I haven't read it closely yet: http://smallcultfollowing.com/babysteps/blog/2015/08/20/virt...