summaryrefslogtreecommitdiff
path: root/passlib/handlers/django.py
diff options
context:
space:
mode:
authorEli Collins <elic@assurancetechnologies.com>2012-04-10 12:14:27 -0400
committerEli Collins <elic@assurancetechnologies.com>2012-04-10 12:14:27 -0400
commitf74deb32c6af1eac658e7d30ee3fe20e8fdf141c (patch)
tree40fe6d4fcc412d2429b01812f629fcf187aa8971 /passlib/handlers/django.py
parent575ad2bfaf04cc1d75d61a30e469b52afdd8ccb8 (diff)
downloadpasslib-f74deb32c6af1eac658e7d30ee3fe20e8fdf141c.tar.gz
passlib.exc: added constructors for common errors, should normalize error messages
Diffstat (limited to 'passlib/handlers/django.py')
-rw-r--r--passlib/handlers/django.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/passlib/handlers/django.py b/passlib/handlers/django.py
index b91c265..9a22a38 100644
--- a/passlib/handlers/django.py
+++ b/passlib/handlers/django.py
@@ -50,13 +50,13 @@ class DjangoSaltedHash(uh.HasSalt, uh.GenericHandler):
@classmethod
def from_string(cls, hash):
if not hash:
- raise ValueError("no hash specified")
+ raise uh.exc.MissingHashError(cls)
if isinstance(hash, bytes):
hash = hash.decode("ascii")
ident = cls.ident
assert ident.endswith(u("$"))
if not hash.startswith(ident):
- raise ValueError("invalid %s hash" % (cls.name,))
+ raise uh.exc.InvalidHashError(cls)
_, salt, chk = hash.split(u("$"))
return cls(salt=salt, checksum=chk or None)
@@ -160,7 +160,7 @@ class django_des_crypt(DjangoSaltedHash):
chk = self.checksum
if salt and chk:
if salt[:2] != chk[:2]:
- raise ValueError("invalid django_des_crypt hash: "
+ raise uh.exc.MalformedHashError(cls,
"first two digits of salt and checksum must match")
# repeat stub checksum detection since salt isn't set
# when _norm_checksum() is called.
@@ -218,7 +218,7 @@ class django_disabled(uh.StaticHandler):
if secret is None:
raise TypeError("no secret provided")
if not cls.identify(hash):
- raise ValueError("invalid django-disabled hash")
+ raise uh.exc.InvalidHashError(cls)
return False
#=========================================================