Skip to content

Commit abd9740

Browse files
author
Paul Tagliamonte
committed
Small tweeks to provide a sane error
1 parent fc1e731 commit abd9740

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

sunlight/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __str__(self):
3434
class BadRequestException(SunlightException):
3535
"""
3636
This gets thrown when the underlying url request has recieved an abnormal
37-
response code.
37+
response code, or the program has issued a request that can not be filled.
3838
"""
3939
pass
4040

sunlight/services/openstates.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# of the LICENSE file.
33

44
import sunlight.service
5+
from sunlight.errors import BadRequestException
56
import json
67

78
module_name = "openstates"
@@ -173,6 +174,11 @@ def district_boundary(self, boundary_id, **kwargs):
173174
# API impl methods
174175

175176
def _get_url(self, objs, apikey, **kwargs):
177+
# Gate for any None's in the query. This is usually a problem.
178+
if None in objs:
179+
raise BadRequestException("`None' passed to the URL encoder (%s)" %
180+
(str(objs)))
181+
176182
# join pieces by slashes and add a trailing slash
177183
object_path = "/".join(objs)
178184
object_path += "/"

0 commit comments

Comments
 (0)