How can I detect when an internal error happens?

When I am testing in roblox studio, once in a blue moon(1/50 about) I get an internal error of some sort, whether it is HTTP 502 or a marketplace error etc. Is there a way to detect when this happens and kick the player if so?

pcall

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

for i=1, 2147483647 do
	local v = math.random(1000000, 2147483647)
	
	local Works, Result = pcall(function()
		return MarketplaceService:GetProductInfo(v)
	end)

	if not Works then
		for i, player in pairs(Players:GetPlayers()) do
			player:Kick("rejoin now")
		end
	else
		print(Result)
	end
end