input: Write a function to create and visualize a simple linear regression model in Python using the provided CSV data. If the CSV file does not exist or the data format is incorrect, return a message indicating the error.
  
  
  import pandas as pd
  import matplotlib.pyplot as plt
  from sklearn import linear_model
  
  def linear_regression_model(csv_file):
      try:
          data = pd.read_csv(csv_file)
          X = data['X'].values.reshape(-1, 1)
          Y = data['Y'].values.reshape(-1, 1)
          model = linear_model.LinearRegression()
          model.fit(X, Y)
          Y_pred = model.predict(X)
          plt.scatter(X, Y)
          plt.plot(X, Y_pred, color='red')
          plt.show()
      except FileNotFoundError:
          return "Error: CSV file not found."
      except KeyError:
          return "Error: Incorrect data format in CSV."
      except Exception as e:
          return f"Error: {str(e)}"
  
  assert linear_regression_model('data.csv')==None
  assert linear_regression_model('nonexistent.csv')=="Error: CSV file not found."
  
output: 
  def linear_regression_model(csv_file):
      try:
          data = pd.read_csv(csv_file)
          X = data['X'].values.reshape(-1, 1)
          Y = data['Y'].values.reshape(-1, 1)
          model = linear_model.LinearRegression()
          model.fit(X, Y)
          Y_pred = model.predict(X)
          plt.scatter(X, Y)
          plt.plot(X, Y_pred, color='red')
          plt.show()
      except FileNotFoundError:
          return "Error: CSV file not found."
      except KeyError:
          return "Error: Incorrect data format in CSV."
      except Exception as e:
          return f"Error: {str(e)}"
  