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
|
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):
|
||||||
|
|
|
@ -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 ''
|
||||||
|
|
|
@ -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 ''
|
||||||
|
|
Ładowanie…
Reference in New Issue