Raise an error for unsupported hook event
authorPaul Matthews <pmatthews@google.com>
Mon, 12 Aug 2013 13:20:25 +0000 (14:20 +0100)
committerPaul Matthews <pmatthews@google.com>
Mon, 12 Aug 2013 14:27:17 +0000 (15:27 +0100)
* Raises a ValueError for an unsupported hook event

requests/models.py

index 6b4a2994428664eb01bed26232c69bd54e41ee26..007a9f1caa7cf5b0ffdb4c3ccded5fa5ac6fe38c 100644 (file)
@@ -141,6 +141,9 @@ class RequestHooksMixin(object):
     def register_hook(self, event, hook):
         """Properly register a hook."""
 
+        if event not in self.hooks:
+            raise ValueError('Unsupported event specified, with event name "%s"' % (event))
+
         if isinstance(hook, collections.Callable):
             self.hooks[event].append(hook)
         elif hasattr(hook, '__iter__'):