title: SqlException conversion to a custom Exception handler
body: <p>I have an existing application which uses MS SQL stored procedures to enforce some business rules.  When an error is detected it is raised as an exception using RAISERROR back to my .Net application.</p>
  
  <p>The .Net application can then use Try/Catch blocks to catch and exceptions and perform and business logic.  The problem is that there are several business rules validated in a single stored procedure.  Which could raise different exceptions.  What is the best way to capture these SQL exceptions and convert them to custom .Net Exception handlers.</p>
  
  <p>For example my stored procedure may throw an exception for RuleA and RuleB.  In my .Net code I can only capture SqlException.  My custom error message for either RuleA or RuleB is returned in the SqlException inner exception.   I could parse the Message string but this is UGLY and if someone changes the implementation in the stored proc. my logic would not pick it up.</p>
  
  <p>What is a preferred method to translate the generic SqlException into MyRuleAException or MyRuleBException?  </p>