Skip to content

Commit

Permalink
Catch '20201 No records found' and return empty SearchResult object
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Liu committed Dec 9, 2016
1 parent 3b59eeb commit 793596b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rets/http/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from rets.http.data import Metadata, Object, SearchResult, SystemMetadata
from rets.http.parsers.http import parse_xml, parse_response
from rets.errors import RetsParseError
from rets.errors import RetsParseError, RetsApiError


def parse_capability_urls(response: Response) -> dict:
Expand Down Expand Up @@ -106,7 +106,13 @@ def parse_system(response: Response) -> SystemMetadata:


def parse_search(response: Response) -> SearchResult:
tag = parse_xml(response)
try:
tag = parse_xml(response)
except RetsApiError as e:
if e.reply_code == 20201: # No records found
return SearchResult(0, False, ())
raise

count_tag = tag.find('COUNT')
try:
data = tuple(_parse_data(tag))
Expand Down

0 comments on commit 793596b

Please sign in to comment.