POST_expando: gracefully fail when called on link with no child.

Previously if POST_expando was called on a link that has no link_child
(i.e. no selftext or media object to show in the expando) it would cause
an exception.

This catches the bad case early and aborts with a 404.
This commit is contained in:
Neil Williams
2013-07-07 12:09:30 -07:00
committed by Chad Birch
parent 8b69aa1635
commit c6fd299788

View File

@@ -3162,7 +3162,10 @@ class ApiController(RedditController, OAuth2ResourceController):
wrapped = wrap_links(link)
wrapped = list(wrapped)[0]
return websafe(spaceCompress(wrapped.link_child.content()))
link_child = wrapped.link_child
if not link_child:
abort(404, 'not found')
return websafe(spaceCompress(link_child.content()))
@validatedForm(VUser('password', default=''),
VModhash(),