Skip to content
Browse files

Add better error report when trying to add the same function twice.

  • Loading branch information...
1 parent f2cf384 commit b4186a01bb93919974ab964160913811dce488c0 @deavid committed Apr 22, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 bjsonrpc/handlers.py
View
11 bjsonrpc/handlers.py
@@ -110,13 +110,20 @@ def add_method(self, *args, **kwargs):
for method in args:
if method.__name__ in self.nonpublic_methods:
continue
- assert(method.__name__ not in self._methods)
+ try:
+ assert(method.__name__ not in self._methods)
+ except AssertionError:
+ raise NameError, "Method with name %s already in the class methods!" % (method.__name__)
self._methods[method.__name__] = method
for name, method in kwargs.iteritems():
if method.__name__ in self.nonpublic_methods:
continue
- assert(name not in self._methods)
+ try:
+ assert(name not in self._methods)
+ except AssertionError:
+ raise NameError, "Method with name %s already in the class methods!" % (method.__name__)
+
self._methods[name] = method
def get_method(self, name):

0 comments on commit b4186a0

Please sign in to comment.
Something went wrong with that request. Please try again.