Skip to content

Commit

Permalink
Better error handling if the API is down
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Dec 13, 2010
1 parent d13a529 commit 1087b34
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion liclient/parsers/lixml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import mappers
import re

class UnavailableAPIService(Exception):
pass


class LinkedInXMLParser(object):
def __init__(self, content):
self.routing = {
Expand All @@ -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)
Expand Down

0 comments on commit 1087b34

Please sign in to comment.