Fixed try catch for logging errors