handle errors in Map's function.