Skip to content

Commit

Permalink
exception handling was hiding original exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Digenis committed Apr 22, 2016
1 parent 04e6e14 commit 2ca8d8a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions parsel/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
XPath selectors based on lxml
"""

import sys

import six
from lxml import etree

Expand Down Expand Up @@ -175,9 +177,10 @@ def xpath(self, query):
try:
result = xpathev(query, namespaces=self.namespaces,
smart_strings=self._lxml_smart_strings)
except etree.XPathError:
msg = u"Invalid XPath: %s" % query
raise ValueError(msg if six.PY3 else msg.encode("unicode_escape"))
except etree.XPathError as exc:
msg = u"XPath error: %s in %s" % (exc, query)
msg = msg if six.PY3 else msg.encode('unicode_escape')
six.reraise(ValueError, ValueError(msg), sys.exc_info()[2])

if type(result) is not list:
result = [result]
Expand Down

0 comments on commit 2ca8d8a

Please sign in to comment.