Comment 0 for bug 1130755

Revision history for this message
Manuel CerĂ³n (ceronman) wrote : Don't raise ImportError when the scheme is unsupported

If you use an unsupported scheme in a connection string, for example:

>>> from storm.locals import *
>>> database = create_database("postgresql://myhost.example.com:5432/mydb")

You get an error like this one:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/test.fluidinfo.com/20130220-1556/fluidinfo/src/storm/storm/database.py", line 546, in create_database
    None, None, [""])
ImportError: No module named postgresql

Note that the correct scheme is "postgres" not "postgresql".

The ImportError is very very misleading. You might think that you're missing a dependency, and spend hours trying to figure out what's going on. That's what just happened to me. :)

It would be *much better* if you catch the ImportError and then raise a different exception with a nice message saying that the scheme is unsupported. Then the typos like the one that I made could be fixed easily. That would improve the usability of the library.

I'm using Storm from trunk.

Thanks.