diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-20 16:25:13 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-20 16:25:13 +0100 |
commit | 56da73969ac49e400ade89248f87c643047221d6 (patch) | |
tree | f1364752f93175b27d91d671069891fc706a3ef7 /src/Wallabag/ApiBundle | |
parent | 70584b42aaa75c2fe9adda5cf6c37ab63adcccb3 (diff) | |
download | wallabag-56da73969ac49e400ade89248f87c643047221d6.tar.gz wallabag-56da73969ac49e400ade89248f87c643047221d6.tar.zst wallabag-56da73969ac49e400ade89248f87c643047221d6.zip |
Return an explicit error if reload fail
Diffstat (limited to 'src/Wallabag/ApiBundle')
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 7b7d94bf..1a726b6e 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -287,7 +287,7 @@ class EntryRestController extends WallabagRestController | |||
287 | 287 | ||
288 | /** | 288 | /** |
289 | * Reload an entry. | 289 | * Reload an entry. |
290 | * An empty response with HTTP Status 304 will be send if we weren't able to update the content (because it hasn't changed or we got an error). | 290 | * A response with HTTP Status 400 will be return if we weren't able to update the content (because it hasn't changed or we got an error). |
291 | * | 291 | * |
292 | * @ApiDoc( | 292 | * @ApiDoc( |
293 | * requirements={ | 293 | * requirements={ |
@@ -302,9 +302,6 @@ class EntryRestController extends WallabagRestController | |||
302 | $this->validateAuthentication(); | 302 | $this->validateAuthentication(); |
303 | $this->validateUserAccess($entry->getUser()->getId()); | 303 | $this->validateUserAccess($entry->getUser()->getId()); |
304 | 304 | ||
305 | // put default title in case of fetching content failed | ||
306 | $entry->setTitle('No title found'); | ||
307 | |||
308 | try { | 305 | try { |
309 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); | 306 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); |
310 | } catch (\Exception $e) { | 307 | } catch (\Exception $e) { |
@@ -313,12 +310,12 @@ class EntryRestController extends WallabagRestController | |||
313 | 'entry' => $entry, | 310 | 'entry' => $entry, |
314 | ]); | 311 | ]); |
315 | 312 | ||
316 | return new JsonResponse([], 304); | 313 | return new JsonResponse(['error' => 'Error while trying to fetch content'], 400); |
317 | } | 314 | } |
318 | 315 | ||
319 | // if refreshing entry failed, don't save it | 316 | // if refreshing entry failed, don't save it |
320 | if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) { | 317 | if ($this->getParameter('wallabag_core.fetching_error_message') === $entry->getContent()) { |
321 | return new JsonResponse([], 304); | 318 | return new JsonResponse(['error' => 'Error while trying to extract content'], 400); |
322 | } | 319 | } |
323 | 320 | ||
324 | $em = $this->getDoctrine()->getManager(); | 321 | $em = $this->getDoctrine()->getManager(); |