Skip to content

Commit

Permalink
Add try/except to page preview API endpoint (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood authored Nov 12, 2024
1 parent 621c7d3 commit 1f7e406
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions etna/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ def get_object(self):
app_label, model = self.request.GET["content_type"].split(".")
content_type = ContentType.objects.get(app_label=app_label, model=model)

page_preview = PagePreview.objects.get(
content_type=content_type, token=self.request.GET["token"]
)
try:
page_preview = PagePreview.objects.get(
content_type=content_type, token=self.request.GET["token"]
)
except PagePreview.DoesNotExist:
raise BadRequestError("Page preview does not exist")
page = page_preview.as_page()
if not page.pk:
# fake primary key to stop API URL routing from complaining
Expand Down

0 comments on commit 1f7e406

Please sign in to comment.