title: Return Error code when using try and except? (without raise)
body: <p>I have some scripts running in docker containers that collect data from yfinance.
  Sometimes crashes occur because the data is not available.</p>
  <p>So I wanted to send me a mail if a crash occurs in a script, but I wanted it to be the exact error code that caused the main function to crash.</p>
  <p>Is there a way that would allow me to return the exact error code as a variable (and send it per mail) instead of just using try and except?</p>
  <pre><code>if __name__ == '__main__':
      try:
          main()
      except:
          ERROR = 'Value Error occured in BOT1'
          print(ERROR)
          sendmail(ERROR)
          sleep_time(1800)
  </code></pre>