Catch all embed exceptions in frontend code

pull/1381/head
Karl Hobley 2015-06-05 14:23:15 +01:00
rodzic 0dc4cbcf21
commit 4c51d97ae5
3 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -15,10 +15,13 @@ from wagtail.wagtailembeds.oembed_providers import get_oembed_provider
from wagtail.wagtailembeds.models import Embed from wagtail.wagtailembeds.models import Embed
class EmbedNotFoundException(Exception): class EmbedException(Exception):
pass pass
class EmbedlyException(Exception): class EmbedNotFoundException(EmbedException):
pass
class EmbedlyException(EmbedException):
pass pass
class AccessDeniedEmbedlyException(EmbedlyException): class AccessDeniedEmbedlyException(EmbedlyException):

Wyświetl plik

@ -20,7 +20,7 @@ def embed_to_frontend_html(url):
'embed': embed, 'embed': embed,
'ratio': ratio, 'ratio': ratio,
}) })
except embeds.EmbedNotFoundException: except embeds.EmbedException:
return '' return ''
@ -32,6 +32,6 @@ def embed_to_editor_html(url):
return render_to_string('wagtailembeds/embed_editor.html', { return render_to_string('wagtailembeds/embed_editor.html', {
'embed': embed, 'embed': embed,
}) })
except embeds.EmbedNotFoundException: except embeds.EmbedException:
# Could be replaced with a nice error message # Could be replaced with a nice error message
return '' return ''

Wyświetl plik

@ -12,5 +12,5 @@ def embed(url, max_width=None):
try: try:
embed = embeds.get_embed(url, max_width=max_width) embed = embeds.get_embed(url, max_width=max_width)
return mark_safe(embed.html) return mark_safe(embed.html)
except embeds.EmbedNotFoundException: except embeds.EmbedException:
return '' return ''