input: Write a python function to detect intent from text using Dialogflow and handle exceptions.
  assert detect_intent_from_text('What is the weather like?', 'session_123').query_text == 'What is the weather like?'
  assert detect_intent_from_text('Tell me a joke', 'session_123').query_text == 'Tell me a joke'
  assert detect_intent_from_text('How are you?', 'session_123').query_text == 'How are you?'
output: def detect_intent_from_text(text, session_id):
      from google.cloud import dialogflow_v2 as dialogflow
      import os
  
      os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "path_to_your_service_account.json"
  
      try:
          session_client = dialogflow.SessionsClient()
          session = session_client.session_path('your_project_id', session_id)
  
          text_input = dialogflow.TextInput(text=text, language_code="en-US")
          query_input = dialogflow.QueryInput(text=text_input)
  
          response = session_client.detect_intent(request={"session": session, "query_input": query_input})
          return response.query_result
  
      except Exception as e:
          print(f"An error occurred: {e}")
          return None