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 committed by Thomas Citharel
parent f06f840c9d
commit 6334f2cac1
12 changed files with 45 additions and 27 deletions

View file

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

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
# entry_already_saved: 'Entry already saved on %date%' # entry_already_saved: 'Entry already saved on %date%'
# entry_saved: 'Entry saved' # entry_saved: 'Entry saved'
# entry_saved_failed: 'Failed to save entry'
# entry_updated: 'Entry updated' # entry_updated: 'Entry updated'
# entry_reloaded: 'Entry reloaded' # entry_reloaded: 'Entry reloaded'
# entry_reload_failed: 'Failed to reload entry' # entry_reload_failed: 'Failed to reload entry'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Eintrag bereits am %date% gespeichert' entry_already_saved: 'Eintrag bereits am %date% gespeichert'
entry_saved: 'Eintag gespeichert' entry_saved: 'Eintag gespeichert'
# entry_saved_failed: 'Failed to save entry'
entry_updated: 'Eintrag aktualisiert' entry_updated: 'Eintrag aktualisiert'
entry_reloaded: 'Eintrag neugeladen' entry_reloaded: 'Eintrag neugeladen'
entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen' entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Entry already saved on %date%' entry_already_saved: 'Entry already saved on %date%'
entry_saved: 'Entry saved' entry_saved: 'Entry saved'
entry_saved_failed: 'Failed to save entry'
entry_updated: 'Entry updated' entry_updated: 'Entry updated'
entry_reloaded: 'Entry reloaded' entry_reloaded: 'Entry reloaded'
entry_reload_failed: 'Failed to reload entry' entry_reload_failed: 'Failed to reload entry'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Entrada ya guardada por %fecha%' entry_already_saved: 'Entrada ya guardada por %fecha%'
entry_saved: 'Entrada guardada' entry_saved: 'Entrada guardada'
# entry_saved_failed: 'Failed to save entry'
entry_updated: 'Entrada actualizada' entry_updated: 'Entrada actualizada'
entry_reloaded: 'Entrada recargada' entry_reloaded: 'Entrada recargada'
entry_reload_failed: 'Entrada recargada reprobada' entry_reload_failed: 'Entrada recargada reprobada'

View file

@ -96,8 +96,8 @@ config:
rule_label: 'قانون' rule_label: 'قانون'
tags_label: 'برچسب‌ها' tags_label: 'برچسب‌ها'
faq: faq:
title: 'پرسش‌های متداول' title: 'پرسش‌های متداول'
tagging_rules_definition_title: 'برچسب‌گذاری خودکار یعنی چه؟' tagging_rules_definition_title: 'برچسب‌گذاری خودکار یعنی چه؟'
# tagging_rules_definition_description: 'They are rules used by Wallabag to automatically tag new entries.<br />Each time a new entry is added, all the tagging rules will be used to add the tags you configured, thus saving you the trouble to manually classify your entries.' # tagging_rules_definition_description: 'They are rules used by Wallabag to automatically tag new entries.<br />Each time a new entry is added, all the tagging rules will be used to add the tags you configured, thus saving you the trouble to manually classify your entries.'
# how_to_use_them_title: 'How do I use them?' # how_to_use_them_title: 'How do I use them?'
# how_to_use_them_description: 'Let assume you want to tag new entries as « <i>short reading</i> » when the reading time is inferior to 3 minutes.<br />In that case, you should put « readingTime &lt;= 3 » in the <i>Rule</i> field and « <i>short reading</i> » in the <i>Tags</i> field.<br />Several tags can added simultaneously by separating them by a comma: « <i>short reading, must read</i> »<br />Complex rules can be written by using predefined operators: if « <i>readingTime &gt;= 5 AND domainName = "github.com"</i> » then tag as « <i>long reading, github </i> »' # how_to_use_them_description: 'Let assume you want to tag new entries as « <i>short reading</i> » when the reading time is inferior to 3 minutes.<br />In that case, you should put « readingTime &lt;= 3 » in the <i>Rule</i> field and « <i>short reading</i> » in the <i>Tags</i> field.<br />Several tags can added simultaneously by separating them by a comma: « <i>short reading, must read</i> »<br />Complex rules can be written by using predefined operators: if « <i>readingTime &gt;= 5 AND domainName = "github.com"</i> » then tag as « <i>long reading, github </i> »'
@ -384,30 +384,31 @@ developer:
flashes: flashes:
config: config:
notice: notice:
config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال می‌شود.' config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال می‌شود.'
password_updated: 'رمز به‌روز شد' password_updated: 'رمز به‌روز شد'
password_not_updated_demo: "در حالت نمایشی نمی‌توانید رمز کاربر را عوض کنید." password_not_updated_demo: "در حالت نمایشی نمی‌توانید رمز کاربر را عوض کنید."
user_updated: 'اطلاعات به‌روز شد' user_updated: 'اطلاعات به‌روز شد'
rss_updated: 'اطلاعات آر-اس-اس به‌روز شد' rss_updated: 'اطلاعات آر-اس-اس به‌روز شد'
tagging_rules_updated: 'برچسب‌گذاری خودکار به‌روز شد' tagging_rules_updated: 'برچسب‌گذاری خودکار به‌روز شد'
tagging_rules_deleted: 'قانون برچسب‌گذاری پاک شد' tagging_rules_deleted: 'قانون برچسب‌گذاری پاک شد'
user_added: 'کابر "%username%" افزوده شد' user_added: 'کابر "%username%" افزوده شد'
rss_token_updated: 'کد آر-اس-اس به‌روز شد' rss_token_updated: 'کد آر-اس-اس به‌روز شد'
entry: entry:
notice: notice:
entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود'
entry_saved: 'مقاله ذخیره شد' entry_saved: 'مقاله ذخیره شد'
entry_updated: 'مقاله به‌روز شد' # entry_saved_failed: 'Failed to save entry'
entry_reloaded: 'مقاله به‌روز شد' entry_updated: 'مقاله به‌روز شد'
entry_reload_failed: 'به‌روزرسانی مقاله شکست خورد' entry_reloaded: 'مقاله به‌روز شد'
entry_archived: 'مقاله بایگانی شد' entry_reload_failed: 'به‌روزرسانی مقاله شکست خورد'
entry_unarchived: 'مقاله از بایگانی درآمد' entry_archived: 'مقاله بایگانی شد'
entry_starred: 'مقاله برگزیده شد' entry_unarchived: 'مقاله از بایگانی درآمد'
entry_unstarred: 'مقاله نابرگزیده شد' entry_starred: 'مقاله برگزیده شد'
entry_deleted: 'مقاله پاک شد' entry_unstarred: 'مقاله نابرگزیده شد'
entry_deleted: 'مقاله پاک شد'
tag: tag:
notice: notice:
tag_added: 'برچسب افزوده شد' tag_added: 'برچسب افزوده شد'
import: import:
notice: notice:
failed: 'درون‌ریزی شکست خورد. لطفاً دوباره تلاش کنید.' failed: 'درون‌ریزی شکست خورد. لطفاً دوباره تلاش کنید.'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Article déjà sauvergardé le %date%' entry_already_saved: 'Article déjà sauvergardé le %date%'
entry_saved: 'Article enregistré' entry_saved: 'Article enregistré'
entry_saved_failed: "L'enregistrement a échoué"
entry_updated: 'Article mis à jour' entry_updated: 'Article mis à jour'
entry_reloaded: 'Article rechargé' entry_reloaded: 'Article rechargé'
entry_reload_failed: "Le rechargement de l'article a échoué" entry_reload_failed: "Le rechargement de l'article a échoué"

View file

@ -396,6 +396,7 @@ flashes:
notice: notice:
entry_already_saved: 'Contenuto già salvato in data %date%' entry_already_saved: 'Contenuto già salvato in data %date%'
entry_saved: 'Contenuto salvato' entry_saved: 'Contenuto salvato'
# entry_saved_failed: 'Failed to save entry'
entry_updated: 'Contenuto aggiornato' entry_updated: 'Contenuto aggiornato'
entry_reloaded: 'Contenuto ricaricato' entry_reloaded: 'Contenuto ricaricato'
entry_reload_failed: 'Errore nel ricaricamento del contenuto' entry_reload_failed: 'Errore nel ricaricamento del contenuto'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Article ja salvargardat lo %date%' entry_already_saved: 'Article ja salvargardat lo %date%'
entry_saved: 'Article enregistrat' entry_saved: 'Article enregistrat'
# entry_saved_failed: 'Failed to save entry'
entry_updated: 'Article mes a jorn' entry_updated: 'Article mes a jorn'
entry_reloaded: 'Article recargat' entry_reloaded: 'Article recargat'
entry_reload_failed: "Fracàs de l'actualizacion de l'article" entry_reload_failed: "Fracàs de l'actualizacion de l'article"

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Wpis już został dodany %date%' entry_already_saved: 'Wpis już został dodany %date%'
entry_saved: 'Wpis zapisany' entry_saved: 'Wpis zapisany'
# entry_saved_failed: 'Failed to save entry'
entry_updated: 'Wpis zaktualizowany' entry_updated: 'Wpis zaktualizowany'
entry_reloaded: 'Wpis ponownie załadowany' entry_reloaded: 'Wpis ponownie załadowany'
entry_reload_failed: 'Błąd ponownego załadowania' entry_reload_failed: 'Błąd ponownego załadowania'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
# entry_already_saved: 'Entry already saved on %date%' # entry_already_saved: 'Entry already saved on %date%'
# entry_saved: 'Entry saved' # entry_saved: 'Entry saved'
# entry_saved_failed: 'Failed to save entry'
# entry_updated: 'Entry updated' # entry_updated: 'Entry updated'
# entry_reloaded: 'Entry reloaded' # entry_reloaded: 'Entry reloaded'
# entry_reload_failed: 'Failed to reload entry' # entry_reload_failed: 'Failed to reload entry'

View file

@ -397,6 +397,7 @@ flashes:
notice: notice:
entry_already_saved: 'Entry already saved on %date%' entry_already_saved: 'Entry already saved on %date%'
entry_saved: 'Makale kaydedildi' entry_saved: 'Makale kaydedildi'
# entry_saved_failed: 'Failed to save entry'
# entry_updated: 'Entry updated' # entry_updated: 'Entry updated'
entry_reloaded: 'Makale içeriği yenilendi' entry_reloaded: 'Makale içeriği yenilendi'
# entry_reload_failed: 'Failed to reload entry' # entry_reload_failed: 'Failed to reload entry'