Skip to content

Commit cb0914f

Browse files
committed
SCP-8 Added PhotoNotFoundException to the list of exceptions and to the sentry ignore list.
1 parent 63bc6f5 commit cb0914f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

exceptions/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .exceptions import JobNotFoundException, StudioException
1+
from .exceptions import JobNotFoundException, StudioException, PhotoNotFoundException
22

3-
__all__ = ['JobNotFoundException', 'StudioException']
3+
__all__ = ['JobNotFoundException', 'StudioException', 'PhotoNotFoundException']

exceptions/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class JobNotFoundException(Exception):
22
def __init__(self, message):
33
super().__init__(message)
4+
class PhotoNotFoundException(Exception):
5+
def __init__(self, message):
6+
super().__init__(message)
47

58
class StudioException(Exception):
69
def __init__(self, status_code, message="Studio exception occurred"):

skylab_studio/studio_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, api_key=None, **kwargs):
8282
# of sampled transactions.
8383
# We recommend adjusting this value in production.
8484
profiles_sample_rate=1.0,
85-
ignore_errors=[JobNotFoundException]
85+
ignore_errors=[JobNotFoundException, PhotoNotFoundException]
8686
)
8787

8888
def _build_http_auth(self):
@@ -508,6 +508,9 @@ async def download_photo(self, photo_id, output_path, profile = None, options =
508508
await semaphore.acquire()
509509

510510
photo = self.get_photo(photo_id)
511+
512+
if not 'job' in photo:
513+
raise PhotoNotFoundException(f"Unable to find photo with id: {photo_id}")
511514
profile_id = photo['job']['profileId']
512515
file_name = photo['name']
513516

0 commit comments

Comments
 (0)