kopia lustrzana https://github.com/wagtail/wagtail
Catch all embed exceptions in frontend code
rodzic
0dc4cbcf21
commit
4c51d97ae5
|
@ -15,10 +15,13 @@ from wagtail.wagtailembeds.oembed_providers import get_oembed_provider
|
|||
from wagtail.wagtailembeds.models import Embed
|
||||
|
||||
|
||||
class EmbedNotFoundException(Exception):
|
||||
class EmbedException(Exception):
|
||||
pass
|
||||
|
||||
class EmbedlyException(Exception):
|
||||
class EmbedNotFoundException(EmbedException):
|
||||
pass
|
||||
|
||||
class EmbedlyException(EmbedException):
|
||||
pass
|
||||
|
||||
class AccessDeniedEmbedlyException(EmbedlyException):
|
||||
|
|
|
@ -20,7 +20,7 @@ def embed_to_frontend_html(url):
|
|||
'embed': embed,
|
||||
'ratio': ratio,
|
||||
})
|
||||
except embeds.EmbedNotFoundException:
|
||||
except embeds.EmbedException:
|
||||
return ''
|
||||
|
||||
|
||||
|
@ -32,6 +32,6 @@ def embed_to_editor_html(url):
|
|||
return render_to_string('wagtailembeds/embed_editor.html', {
|
||||
'embed': embed,
|
||||
})
|
||||
except embeds.EmbedNotFoundException:
|
||||
except embeds.EmbedException:
|
||||
# Could be replaced with a nice error message
|
||||
return ''
|
||||
|
|
|
@ -12,5 +12,5 @@ def embed(url, max_width=None):
|
|||
try:
|
||||
embed = embeds.get_embed(url, max_width=max_width)
|
||||
return mark_safe(embed.html)
|
||||
except embeds.EmbedNotFoundException:
|
||||
except embeds.EmbedException:
|
||||
return ''
|
||||
|
|
Ładowanie…
Reference in New Issue