SPOT-583: Added try-except logic to catch the error