Validation Exceptions
Posted on September 15, 2008This one bugs me. Scott Guthrie has a huge post on some new form stuff that comes with preview 5. Great info there. However, looking at the validation examples, you can see that the validation depends on on checking business rules and throwing exceptions if any of the rules fail; then in the controller you catch a general System.Exception, update some stuff for the view, and return the same view. Why is this bad?
Well, an exception didn't really occur, it was made up because of failing a known business rule. So basically, now you're using the throwing of exceptions to guide your workflow which makes your code hard to test and hard to follow. I wouldn't normally comment on something like this, but I saw another example of this by Stephen Walther here.
People, please don't throw exceptions in non-exceptional situations.