Catch an exception if there's a database failure

This uses a try/catch for handling a database error. It's pretty hard to test the failure side of things but you can check updating Joomla works as expected still.