input: Write a function to scrape the table at the URL provided and extract the planets information (name, mass, and distance from the sun). If the table is not found, return an empty list. Ensure the function handles exceptions gracefully.
  assert scrape_planets('https://en.wikipedia.org/wiki/List_of_gravitationally_rounded_objects_of_the_Solar_System')==[{'name': 'Mercury', 'mass': '0.0553 (±0.0001)', 'distance_from_sun': '0.387 (±0.00002)', ...}]
  assert scrape_planets('https://invalidurl.com')==[]
  assert scrape_planets('https://en.wikipedia.org/wiki/Main_Page')==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def scrape_planets(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.content, 'html.parser')
          table = soup.find('table', {'class': 'wikitable'})
          if not table:
              return []
          rows = table.find_all('tr')
          planets = []
          for row in rows[1:]:
              cols = row.find_all('td')
              if len(cols) >= 3:
                  name = cols[0].get_text(strip=True)
                  mass = cols[1].get_text(strip=True)
                  distance_from_sun = cols[2].get_text(strip=True)
                  planets.append({'name': name, 'mass': mass, 'distance_from_sun': distance_from_sun})
          return planets
      except Exception as e:
          return []