Catching exceptions from db