Permalink
Browse files

Move exceptions into their own file.

  • Loading branch information...
brianloveswords committed Jun 2, 2011
1 parent b0a3e7f commit 0513a9561aa18ffb40ff1ec0b5fb1baf9de60334
Showing with 14 additions and 11 deletions.
  1. +1 −5 jws/__init__.py
  2. +1 −3 jws/algos.py
  3. +10 −0 jws/exceptions.py
  4. +2 −3 jws/header.py
View
@@ -3,11 +3,8 @@
# local
import algos
import header
-from algos import SignatureError
+from exceptions import *
-class MissingKey(Exception): pass
-class MissingSigner(Exception): pass
-class MissingVerifier(Exception): pass
##############
# public api #
##############
@@ -52,4 +49,3 @@ def verify(head, payload, encoded_signature, key=None):
def _signing_input(head, payload):
head_input, payload_input = map(utils.encode, [head, payload])
return "%s.%s" % (head_input, payload_input)
-
View
@@ -1,6 +1,6 @@
import re
-class SignatureError(Exception): pass
+from exceptions import SignatureError, RouteMissingError, RouteEndpointError
class AlgorithmBase(object):
"""Base for algorithm support classes."""
supported_bits = (256, 384, 512)
@@ -134,8 +134,6 @@ def verify(self, msg, crypto, key):
return True
# algorithm routing
-class RouteMissingError(Exception): pass
-class RouteEndpointError(Exception): pass
def route(name):
return resolve(*find(name))
View
@@ -0,0 +1,10 @@
+class MissingKey(Exception): pass
+class MissingSigner(Exception): pass
+class MissingVerifier(Exception): pass
+
+class SignatureError(Exception): pass
+class RouteMissingError(Exception): pass
+class RouteEndpointError(Exception): pass
+
+class ParameterNotUnderstood(Exception): pass
+class AlgorithmNotImplemented(Exception): pass
View
@@ -1,4 +1,5 @@
import algos
+from exceptions import ParameterNotUnderstood, AlgorithmNotImplemented, RouteMissingError
class HeaderBase(object):
def __init__(self, name, value, data):
self.name = name
@@ -20,17 +21,15 @@ class VerifyNotImplemented(HeaderBase):
def verify(self):
raise "Header Paramter %s not implemented in the context of verifying" % self.name
-class ParameterNotUnderstood(Exception): pass
class NotImplemented(HeaderBase):
def clean(self, *a):
raise ParameterNotUnderstood("Could not find an action for Header Paramter '%s'" % self.name)
-class AlgorithmNotImplemented(Exception): pass
class Algorithm(HeaderBase):
def clean(self, value):
try:
self.methods = algos.route(value)
- except algos.RouteMissingError, e:
+ except RouteMissingError, e:
raise AlgorithmNotImplemented('"%s" not implemented.' % value)
def sign(self):

0 comments on commit 0513a95

Please sign in to comment.