The other day on ou开发者_运维问答r production DB we had a few bad queries come to light that caused some blocking in our productions systems. While these queries have been fixed, there was another problem that somehow our application started displaying the message "A type 1000 server error has occurred". I'm trying to update our application to appropriately handle this, unfortunately I don't seem to be able to easily regenerate the state SQL server was in that caused this error. Is there a way to "short circuit" a request to SQL so the DB will give a response but indicate that it is in a "locked" or "unable to execute" state?
In SQL, you could use TRY...Catch to return whatever response you want.
Mock Objects are the "BestWay(tm)" to test this type of behavior. If you don't have a testing framework (e.g. PHPUnit) to facilitate this, there are fewer options.
- You can hack up the response object, like @Marc B suggested, which is like using Mock Objects, but in a less-formal way.
- You can also set up a dev environment which points to an instance of SqlServer that you can abuse.
精彩评论