Skip to content

Commit f6c0b3a

Browse files
committed
Add custom exception for Presentation Links
1 parent 1043950 commit f6c0b3a

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

frameioclient/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import re
12
import sys
23
import requests
34
import warnings
45
from requests.adapters import HTTPAdapter
56
from requests.packages.urllib3.util.retry import Retry
67
from .download import FrameioDownloader
8+
from .exceptions import PresentationException
79

810
if sys.version_info.major >= 3:
911
from .py3_uploader import FrameioUploader
@@ -75,6 +77,9 @@ def _api_call(self, method, endpoint, payload={}):
7577
)
7678

7779
return r.json()
80+
81+
if r.status_code == 422 and "presentation" in endpoint:
82+
raise PresentationException
7883

7984
return r.raise_for_status()
8085

frameioclient/exceptions.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
class PresentationException(Exception):
3+
"""Exception raised when you try to create a Presentation Link for an asset
4+
that already has one.
5+
6+
Attributes:
7+
asset_id -- input asset ID
8+
"""
9+
10+
def __init__(
11+
self,
12+
message="Your asset already has a presentation link associated with it."
13+
):
14+
self.message = message
15+
super().__init__(self.message)

0 commit comments

Comments
 (0)