Repository: zooniverse/panoptes-python-client

Issue:
Raise something better than StopIteration in .find() when nothing is found
https://github.com/zooniverse/panoptes-python-client/blob/67e11e16cd91689e62939a6ba54ff7769259a525/panoptes_client/panoptes.py#L428

Discussion:

Patch:
diff --git a/panoptes_client/project.py b/panoptes_client/project.py
index fa67fd1..807d3b7 100644
--- a/panoptes_client/project.py
+++ b/panoptes_client/project.py
@@ -30,7 +30,12 @@ class Project(PanoptesObject):
     def find(cls, id='', slug=None):
         if not id and not slug:
             return None
-        return cls.where(id=id, slug=slug).next()
+        try:
+            return cls.where(id=id, slug=slug).next()
+        except StopIteration:
+            raise PanoptesAPIException(
+                "Could not find project with slug='{}'".format(slug)
+            )
 
     def get_export(
         self,


Test patch:
diff --git a/panoptes_client/tests/test_project.py b/panoptes_client/tests/test_project.py
index d900b75..14effae 100644
--- a/panoptes_client/tests/test_project.py
+++ b/panoptes_client/tests/test_project.py
@@ -1,6 +1,7 @@
 import unittest
 
 from panoptes_client import Project
+from panoptes_client.panoptes import PanoptesAPIException
 
 
 class TestProject(unittest.TestCase):
@@ -17,5 +18,5 @@ class TestProject(unittest.TestCase):
         self.assertEqual(p, None)
 
     def test_find_unknown_slug(self):
-        with self.assertRaises(StopIteration):
+        with self.assertRaises(PanoptesAPIException):
             Project.find(slug='invalid_slug')