Skip to content

Commit

Permalink
Fixed #12718 -- Tighten up the error handling when loading database r…
Browse files Browse the repository at this point in the history
…outers. Thanks to Jeff Balogh for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12336 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Jan 28, 2010
1 parent 7856a75 commit 0cdd36f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django/db/utils.py
Expand Up @@ -95,11 +95,12 @@ def __init__(self, routers):
try: try:
module_name, klass_name = r.rsplit('.', 1) module_name, klass_name = r.rsplit('.', 1)
module = import_module(module_name) module = import_module(module_name)
router = getattr(module, klass_name)()
except ImportError, e: except ImportError, e:
raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e)) raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
try:
router = getattr(module, klass_name)()
except AttributeError: except AttributeError:
raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name)) raise ImproperlyConfigured('Module "%s" does not define a database router name "%s"' % (module, klass_name))
else: else:
router = r router = r
self.routers.append(router) self.routers.append(router)
Expand Down

0 comments on commit 0cdd36f

Please sign in to comment.