title: RAISERROR―How to distinguish with SqlException?
body: <p>I have some 3-4 stored procedures ― which I can modify if needed ― that  use <code>RAISERROR</code> to inform my application of some fatal errors on the database side. Some of these stored procedures are executed from the C# side with <code>ExecuteNonQuery</code>, while other are executed with <code>ExecuteReader</code>. At the moment, I am wrapping these command in a <code>try { ... } catch (SqlException ThisSqlException) { ... }</code> block, but the problem is that this exception will be thrown in at least two scenarios I must deal with separately:</p>
  
  <p>1) Errors with the connection itself, or with faulted or type-mismatched parameters; and</p>
  
  <p>2) Errors that occur whenever I use <code>RAISERROR</code> explicitly.</p>
  
  <p>Since this is a WCF application, I must return to the client application different feedback based on the nature of the exception (whether it was due to a <code>RAISERROR</code> command or not). How can I, then, distinguish between both situations?</p>