Try … Catch in SQL

The best practice to run SQL queries is to run them in transaction and wrap with SQL’s Try … Catch statement, so we could rollback the transaction, and throw an exception. Below is the code snippet that would do it all.

https://gist.github.com/ignas-sakalauskas/3a8d612d60a1250ab2b867a833937c6b