Skip to content
Myr

shorten output when ImportError due to app bug.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Before: ``` C:\dev\tmp>py -2 -m flask run Traceback (most recent call last): File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "C:\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "c:\dev\sourcetree\flask\flask\__main__.py", line 15, in <module> main(as_module=True) File "c:\dev\sourcetree\flask\flask\cli.py", line 523, in main cli.main(args=args, prog_name=name) File "c:\dev\sourcetree\flask\flask\cli.py", line 383, in main return AppGroup.main(self, *args, **kwargs) File "C:\Python27\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) File "C:\Python27\lib\site-packages\click\core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Python27\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke return callback(*args, **kwargs) File "C:\Python27\lib\site-packages\click\decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args[1:], **kwargs) File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke return callback(*args, **kwargs) File "c:\dev\sourcetree\flask\flask\cli.py", line 433, in run_command app = DispatchingApp(info.load_app, use_eager_loading=eager_loading) File "c:\dev\sourcetree\flask\flask\cli.py", line 153, in __init__ self._load_unlocked() File "c:\dev\sourcetree\flask\flask\cli.py", line 177, in _load_unlocked self._app = rv = self.loader() File "c:\dev\sourcetree\flask\flask\cli.py", line 238, in load_app rv = locate_app(self.app_import_path) File "c:\dev\sourcetree\flask\flask\cli.py", line 91, in locate_app __import__(module) File "C:\dev\tmp\error.py", line 1, in <module> import whatisthisidonteven ImportError: No module named whatisthisidonteven ``` After: ``` C:\dev\tmp>py -2 -m flask run Usage: python -m flask run [OPTIONS] Error: There was an error trying to import the app (error): Traceback (most recent call last): File "c:\dev\sourcetree\flask\flask\cli.py", line 91, in locate_app __import__(module) File "C:\dev\tmp\error.py", line 1, in <module> import whatisthisidonteven ImportError: No module named whatisthisidonteven```

authored by Ed Brannin · committed by GitHub · parent 6efea34 · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:flask/cli.py+3 added-1 removed
91 unmodified lines
92 except ImportError:93 # Reraise the ImportError if it occurred within the imported module.94 # Determine this by checking whether the trace has a depth > 1.95 if sys.exc_info()[-1].tb_next:96 raise96 stack_trace = traceback.format_exc()97 raise NoAppException('There was an error trying to import'98 ' the app (%s):\n%s' % (module, stack_trace))99 else:100 raise NoAppException('The file/path provided (%s) does not appear'101 ' to exist. Please verify the path is '102 'correct. If app is not on PYTHONPATH, '
427 unmodified lines