Add a try catch block

This function might also be called before ownCloud is setup which results in a PHP fatal error. We therefore should gracefully catch errors in there.