diff options
author | jcass <john.cass77@gmail.com> | 2015-12-28 18:36:16 +0200 |
---|---|---|
committer | jcass <john.cass77@gmail.com> | 2015-12-28 18:36:16 +0200 |
commit | e6335911d8763cf4bfaa709364e0dc6fc9d60f12 (patch) | |
tree | 438eda651605e3f222e4f5913d8d24846c3cfd2b /pandora | |
parent | d2a520dbf6257986128d14a6c7d23aa37725d5e3 (diff) | |
download | pydora-e6335911d8763cf4bfaa709364e0dc6fc9d60f12.tar.bz2 pydora-e6335911d8763cf4bfaa709364e0dc6fc9d60f12.tar.xz pydora-e6335911d8763cf4bfaa709364e0dc6fc9d60f12.zip |
Align with using Pandora's ParameterMissing exception for ValueErrors.
Diffstat (limited to 'pandora')
-rw-r--r-- | pandora/client.py | 4 | ||||
-rw-r--r-- | pandora/models/pandora.py | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/pandora/client.py b/pandora/client.py index fafd872..4a8a26d 100644 --- a/pandora/client.py +++ b/pandora/client.py | |||
@@ -262,8 +262,8 @@ class APIClient(BaseAPIClient): | |||
262 | from .models.pandora import AdItem | 262 | from .models.pandora import AdItem |
263 | 263 | ||
264 | if not station_id: | 264 | if not station_id: |
265 | raise ValueError("The 'station_id' param must be defined, " | 265 | raise errors.ParameterMissing("The 'station_id' param must be " |
266 | "got: '{}'".format(station_id)) | 266 | "defined, got: '{}'".format(station_id)) |
267 | 267 | ||
268 | ad_metadata = self.get_ad_metadata(ad_token) | 268 | ad_metadata = self.get_ad_metadata(ad_token) |
269 | ad_metadata["stationId"] = station_id | 269 | ad_metadata["stationId"] = station_id |
diff --git a/pandora/models/pandora.py b/pandora/models/pandora.py index 6abd3a7..3a901e5 100644 --- a/pandora/models/pandora.py +++ b/pandora/models/pandora.py | |||
@@ -1,6 +1,7 @@ | |||
1 | from .. import BaseAPIClient | 1 | from .. import BaseAPIClient |
2 | from . import with_metaclass, ModelMetaClass | 2 | from . import with_metaclass, ModelMetaClass |
3 | from . import Field, PandoraModel, PandoraListModel, PandoraDictListModel | 3 | from . import Field, PandoraModel, PandoraListModel, PandoraDictListModel |
4 | from ..errors import ParameterMissing | ||
4 | 5 | ||
5 | 6 | ||
6 | class Station(PandoraModel): | 7 | class Station(PandoraModel): |
@@ -231,13 +232,13 @@ class AdItem(PlaylistModel): | |||
231 | if self.tracking_tokens: | 232 | if self.tracking_tokens: |
232 | self._api_client.register_ad(station_id, self.tracking_tokens) | 233 | self._api_client.register_ad(station_id, self.tracking_tokens) |
233 | else: | 234 | else: |
234 | raise ValueError('No ad tracking tokens available for ' | 235 | raise ParameterMissing('No ad tracking tokens available ' |
235 | 'registration.') | 236 | 'for registration.') |
236 | 237 | ||
237 | def prepare_playback(self): | 238 | def prepare_playback(self): |
238 | try: | 239 | try: |
239 | self.register_ad(self.station_id) | 240 | self.register_ad(self.station_id) |
240 | except ValueError as e: | 241 | except ParameterMissing as e: |
241 | if not self.tracking_tokens: | 242 | if not self.tracking_tokens: |
242 | # Ignore registration attempts if no ad tracking tokens are | 243 | # Ignore registration attempts if no ad tracking tokens are |
243 | # available | 244 | # available |