1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-07-12 16:58:37 +00:00

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.
This commit is contained in:
Jeremy Benoist 2016-05-30 14:32:41 +02:00
parent 2c045a210a
commit 39ba51ca1a
12 changed files with 45 additions and 27 deletions

View file

@ -23,10 +23,16 @@ class EntryController extends Controller
{
try {
$entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
$em = $this->getDoctrine()->getManager();
$em->persist($entry);
$em->flush();
} catch (\Exception $e) {
$this->get('logger')->error('Error while saving an entry', [
'exception' => $e,
'entry' => $entry,
]);
return false;
}
@ -60,11 +66,12 @@ class EntryController extends Controller
return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()]));
}
$this->updateEntry($entry);
$this->get('session')->getFlashBag()->add(
'notice',
'flashes.entry.notice.entry_saved'
);
$message = 'flashes.entry.notice.entry_saved';
if (false === $this->updateEntry($entry)) {
$message = 'flashes.entry.notice.entry_saved_failed';
}
$this->get('session')->getFlashBag()->add('notice', $message);
return $this->redirect($this->generateUrl('homepage'));
}