Catch javascript errors thrown inside the whitelist function