Skip to content

Commit

Permalink
Show more verbose message on import errors
Browse files Browse the repository at this point in the history
ImportError is not always 'module not found', so we should display
more verbose message when this exception occured.

For example message:

    aiohttp.web: error: unable to import defiler.server: No module named 'aiomysql'

is more useful then:

    aiohttp.web: error: module 'defiler.server' not found
  • Loading branch information
Sergey Skripnick committed Oct 18, 2016
1 parent de17c89 commit 9528f4a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ def main(argv):
arg_parser.error("relative module names not supported")
try:
module = import_module(mod_str)
except ImportError:
arg_parser.error("module %r not found" % mod_str)
except ImportError as ex:
arg_parser.error("unable to import %s: %s" % (mod_str, ex))
try:
func = getattr(module, func_str)
except AttributeError:
Expand Down

0 comments on commit 9528f4a

Please sign in to comment.