diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-05-30 14:32:41 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2016-06-23 09:15:50 +0200 |
commit | 6334f2cac16158a0ea4a8e540ace17550085942b (patch) | |
tree | 6772765ca415af66ac1d6871a3475492ebfeb4d0 /src/Wallabag/CoreBundle/Controller/EntryController.php | |
parent | f06f840c9d5e08b81d56e0588dee8249bd2f19af (diff) | |
download | wallabag-6334f2cac16158a0ea4a8e540ace17550085942b.tar.gz wallabag-6334f2cac16158a0ea4a8e540ace17550085942b.tar.zst wallabag-6334f2cac16158a0ea4a8e540ace17550085942b.zip |
Display a message when saving an entry failed
When saving an entry fail because of database error we previously just returned `false`.
Now we got an error in the log and the displayed notice to the user is updated too.
Diffstat (limited to 'src/Wallabag/CoreBundle/Controller/EntryController.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/EntryController.php | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 69dfd4b1..33b5e2ad 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -23,10 +23,16 @@ class EntryController extends Controller | |||
23 | { | 23 | { |
24 | try { | 24 | try { |
25 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); | 25 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); |
26 | |||
26 | $em = $this->getDoctrine()->getManager(); | 27 | $em = $this->getDoctrine()->getManager(); |
27 | $em->persist($entry); | 28 | $em->persist($entry); |
28 | $em->flush(); | 29 | $em->flush(); |
29 | } catch (\Exception $e) { | 30 | } catch (\Exception $e) { |
31 | $this->get('logger')->error('Error while saving an entry', [ | ||
32 | 'exception' => $e, | ||
33 | 'entry' => $entry, | ||
34 | ]); | ||
35 | |||
30 | return false; | 36 | return false; |
31 | } | 37 | } |
32 | 38 | ||
@@ -60,11 +66,12 @@ class EntryController extends Controller | |||
60 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); | 66 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); |
61 | } | 67 | } |
62 | 68 | ||
63 | $this->updateEntry($entry); | 69 | $message = 'flashes.entry.notice.entry_saved'; |
64 | $this->get('session')->getFlashBag()->add( | 70 | if (false === $this->updateEntry($entry)) { |
65 | 'notice', | 71 | $message = 'flashes.entry.notice.entry_saved_failed'; |
66 | 'flashes.entry.notice.entry_saved' | 72 | } |
67 | ); | 73 | |
74 | $this->get('session')->getFlashBag()->add('notice', $message); | ||
68 | 75 | ||
69 | return $this->redirect($this->generateUrl('homepage')); | 76 | return $this->redirect($this->generateUrl('homepage')); |
70 | } | 77 | } |