'app' may not have been initialized if an exception occurs

using logging.exception()