title: Sentry with Flask on AWS Lambda not capturing errors
body: <p>I've deployed a flask application on AWS lambda. To perform error tracking I want to integrate Sentry into the application. Here is my setup for the application</p>
  
  <pre><code>def _handle_error(e):
      code = 500
      msg = 'Not Found'
  
      if isinstance(e, HTTPException):
          code = 404
      elif isinstance(e, ValueError):
          msg = str(e)
  
      logging.exception(e)
  
      if os.getenv('SENTRY_DSN'):
          event_id = sentry_sdk.capture_exception(e)
          logging.info(f'Error event was sent to sentry, event id: {event_id}')
  
      return jsonify({'error': msg}), code
  
  
  def create_app():
      app = Flask(__name__)
      CORS(app, support_credentials=True)
  
      if os.getenv('SENTRY_DSN'):
          sentry_logging = LoggingIntegration(
              level=logging.DEBUG,     # Capture info and above as breadcrumbs
              event_level=logging.ERROR  # Send errors as events
          )
  
          sentry_sdk.init(dsn=os.getenv('SENTRY_DSN'),
                          integrations=[FlaskIntegration(), sentry_logging])
  
      app.register_blueprint(bp_routes)
  
      app.register_error_handler(Exception, _handle_error)
  </code></pre>
  
  <p>I use the custom error handler in flask to be able to return a generic error message without any sensitive information. When capturing the error I'm trying to manually create an event in Sentry </p>
  
  <pre><code>event_id = sentry_sdk.capture_exception(e)
  </code></pre>
  
  <p>Running the the code locally with <code>python application.py</code> everything works, the event is created in Sentry with the expected values.</p>
  
  <p>When deploying the same code to lambda the event is no longer generated. </p>
  
  <p>Also when I remove the custom flask error handler</p>
  
  <pre><code># app.register_error_handler(Exception, _handle_error)
  </code></pre>
  
  <p>and deploy it to lambda the event IS generated!</p>
  
  <p>Why is it the <code>capture_exception</code> not working on lambda?</p>