Include raw_response in error message in weather segment
Closes #1112 Ref #1119
This commit is contained in:
parent
f5b9fc24e4
commit
1350fbe88e
|
@ -139,11 +139,16 @@ class WeatherSegment(KwThreadedSegment):
|
||||||
raw_response = urllib_read(url)
|
raw_response = urllib_read(url)
|
||||||
if not raw_response:
|
if not raw_response:
|
||||||
self.error('Failed to get response')
|
self.error('Failed to get response')
|
||||||
return
|
return None
|
||||||
|
|
||||||
response = json.loads(raw_response)
|
response = json.loads(raw_response)
|
||||||
condition = response['query']['results']['weather']['rss']['channel']['item']['condition']
|
try:
|
||||||
condition_code = int(condition['code'])
|
condition = response['query']['results']['weather']['rss']['channel']['item']['condition']
|
||||||
temp = float(condition['temp'])
|
condition_code = int(condition['code'])
|
||||||
|
temp = float(condition['temp'])
|
||||||
|
except (KeyError, ValueError):
|
||||||
|
self.exception('Yahoo returned malformed or unexpected response: {0}', repr(raw_response))
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
icon_names = weather_conditions_codes[condition_code]
|
icon_names = weather_conditions_codes[condition_code]
|
||||||
|
|
Loading…
Reference in New Issue