Skip to content
Myr

Raise an error for unsupported hook event

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Raises a ValueError for an unsupported hook event

authored by Paul Matthews · committed by Paul Matthews · parent d3b7863 · Browse files · 1 file+3 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−0 removed

  • other:+3 added−0 removed

1 file+3 added−0 removed

modified:requests/models.py+3 added
139 unmodified lines
140class RequestHooksMixin(object):141 def register_hook(self, event, hook):142 """Properly register a hook."""143144 if event not in self.hooks:145 raise ValueError('Unsupported event specified, with event name "%s"' % (event))146147 if isinstance(hook, collections.Callable):148 self.hooks[event].append(hook)149 elif hasattr(hook, '__iter__'):150 self.hooks[event].extend(h for h in hook if isinstance(h, collections.Callable))
577 unmodified lines