4 ms·
I'm a tiny bit disappointed with the inclusion of exception filters, but I suppose it is pragmatic feature. I'm fond of a pattern where error codes can be impl
by noblethrasher 12y ago
I'm a tiny bit disappointed with the inclusion of exception filters, but I suppose it is pragmatic feature.
I'm fond of a pattern where error codes can be implicitly converted to Exceptions[1].
It's often argued that exceptions are for things that your program cannot handle and error codes are for things that it can. But, in my experience, whether or not a bad condition is an error or an exception depends upon the layer in which the code lives.
Also, a side benefit of this scheme is that most of the exceptions show up in the class browser, or can be explored through reflection.
[1]https://gist.github.com/noblethrasher/ba37ed6176ebeb679dd2 https://gist.github.com/noblethrasher/ba37ed6176ebeb679dd2 -- In my example, the error code is an integer, but it could be another class that holds more information about the operation.
- hkon 12y agoI've never seen the arguments for error codes vs exception. Care to explain briefly or link me some information?
- noblethrasher 12y agoHere's the first essay I remember on the subject: http://www.joelonsoftware.com/items/2003/10/13.html http://www.joelonsoftware.com/items/2003/10/13.html