Skip to content

Commit 5edbbca

Browse files
rgkimballbashtage
authored andcommitted
Implements output error function, merge conflicts
1 parent 7a4abda commit 5edbbca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas_datareader/base.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,28 @@ def _get_response(self, url, params=None, headers=None):
133133
# Get a new breadcrumb if necessary, in case ours is invalidated
134134
if isinstance(params, list) and 'crumb' in params:
135135
params['crumb'] = self._get_crumb(self.retry_count)
136+
137+
# If our output error function returns True, exit the loop.
138+
if self._output_error(response):
139+
break
140+
136141
if params is not None and len(params) > 0:
137142
url = url + "?" + urlencode(params)
143+
138144
raise RemoteDataError('Unable to read URL: {0}'.format(url))
139145

140146
def _get_crumb(self, *args):
141147
""" To be implemented by subclass """
142148
raise NotImplementedError("Subclass has not implemented method.")
143149

150+
def _output_error(self, out):
151+
"""If necessary, a service can implement an interpreter for any non-200 HTTP responses.
152+
153+
:param out: raw output from an HTTP request
154+
:return: boolean
155+
"""
156+
return False
157+
144158
def _read_lines(self, out):
145159
rs = read_csv(out, index_col=0, parse_dates=True,
146160
na_values=('-', 'null'))[::-1]

0 commit comments

Comments
 (0)