Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix error path in HTTPEndPoint #187

Merged
merged 1 commit into from
Feb 24, 2018

Conversation

dopplershift
Copy link
Member

We were assuming that Content-Type was always available in the headers, which isn't the case when NCSS fails.

This changes:

Traceback (most recent call last):
  File "250hPa_Hemispheric_Plot.py", line 46, in <module>
    data = ncss.get_data(gfsdata)
  File "/Users/rmay/repos/siphon/siphon/ncss.py", line 114, in get_data
    resp = self.get_query(query)
  File "/Users/rmay/repos/siphon/siphon/http_util.py", line 379, in get_query
    return self.get(url, query)
  File "/Users/rmay/repos/siphon/siphon/http_util.py", line 457, in get
    if resp.headers['Content-Type'].startswith('text/html'):
  File "/Users/rmay/miniconda3/envs/py36/lib/python3.6/site-packages/requests/structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'content-type'

to

Traceback (most recent call last):
  File "250hPa_Hemispheric_Plot.py", line 46, in <module>
    data = ncss.get_data(gfsdata)
  File "/Users/rmay/repos/siphon/siphon/ncss.py", line 114, in get_data
    resp = self.get_query(query)
  File "/Users/rmay/repos/siphon/siphon/http_util.py", line 379, in get_query
    return self.get(url, query)
  File "/Users/rmay/repos/siphon/siphon/http_util.py", line 463, in get
    text))
requests.exceptions.HTTPError: Error accessing http://thredds.ucar.edu/thredds/ncss/grib/NCEP/GFS/Global_0p5deg/GFS_Global_0p5deg_20180223_1200.grib2?var=u-component_of_wind_isobaric&var=v-component_of_wind_isobaric&var=Geopotential_height_isobaric&time=2018-02-23T22%3A28%3A49.823819&west=0&east=360&south=0&north=90&accept=netcdf4&addLatLon=True&vertCoord=25000: 400 Requested time 2018-02-23T22:28:49.823Z does not intersect actual time range 2018-02-26T06:00:00Z - 2018-02-26T06:00:00Z

We were assuming that Content-Type was always available in the headers,
which isn't the case when NCSS fails.
Copy link
Contributor

@jrleeman jrleeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another corner case down!

@dopplershift dopplershift merged commit de8764c into Unidata:master Feb 24, 2018
@dopplershift dopplershift deleted the fix-error-handling branch February 24, 2018 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants