Permalink
Browse files

Better error handling if the API is down

  • Loading branch information...
1 parent d13a529 commit 1087b34278dffe69ea6a0d1cbb78a42963c1bf3b @pydanny pydanny committed Dec 13, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 liclient/parsers/lixml.py
View
@@ -2,6 +2,10 @@
import mappers
import re
+class UnavailableAPIService(Exception):
+ pass
+
+
class LinkedInXMLParser(object):
def __init__(self, content):
self.routing = {
@@ -17,7 +21,11 @@ def __init__(self, content):
}
self.tree = etree.fromstring(content)
self.root = self.tree.tag
- self.results = self.__forward_tree(self.tree, self.root)
+ try:
+ self.results = self.__forward_tree(self.tree, self.root)
+ except KeyError as e:
+ raise UnavailableAPIService(e)
+
def __forward_tree(self, tree, root):
results = self.routing[root](tree)

0 comments on commit 1087b34

Please sign in to comment.