Exception catching to log problems properly.