Skip to content

Commit 48d9696

Browse files
committed
Created 'UnsupportedXmlrpcMethodError' exception.
1 parent 7bda6db commit 48d9696

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

wordpress_xmlrpc/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import collections
33
import types
44

5-
from wordpress_xmlrpc.exceptions import ServerConnectionError
5+
from wordpress_xmlrpc.exceptions import ServerConnectionError, UnsupportedXmlrpcMethodError
66

77

88
class Client(object):
@@ -26,7 +26,9 @@ def __init__(self, url, username, password, blog_id=0):
2626
raise ServerConnectionError(repr(e))
2727

2828
def call(self, method):
29-
assert (method.method_name in self.supported_methods)
29+
if method.method_name not in self.supported_methods:
30+
raise UnsupportedXmlrpcMethodError(method.method_name)
31+
3032
server_method = getattr(self.server, method.method_name)
3133
args = method.get_args(self)
3234
raw_result = server_method(*args)

wordpress_xmlrpc/exceptions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ class ServerConnectionError(Exception):
55
pass
66

77

8+
class UnsupportedXmlrpcMethodError(Exception):
9+
"""
10+
An error while attempting to call a method that is not
11+
supported by the XML-RPC server.
12+
"""
13+
pass
14+
15+
816
class FieldConversionError(Exception):
917
"""
1018
An error while converting field Python value to XML-RPC value type.

0 commit comments

Comments
 (0)