]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Display a message when saving an entry failed
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 30 May 2016 12:32:41 +0000 (14:32 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 30 May 2016 12:32:43 +0000 (14:32 +0200)
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.

12 files changed:
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml

index 69dfd4b108a12e305943a35d908acde9a1a60215..33b5e2ad03905232dad0df1f0e130275e30853c7 100644 (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'));
         }
index 8d3920630228b0c1dc995c23432d83dd58700562..0c2a3249b664c4a8441b1905c68e3b02f3da5685 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             # entry_already_saved: 'Entry already saved on %date%'
             # entry_saved: 'Entry saved'
+            # entry_saved_failed: 'Failed to save entry'
             # entry_updated: 'Entry updated'
             # entry_reloaded: 'Entry reloaded'
             # entry_reload_failed: 'Failed to reload entry'
index c7a8949296cb3efbf945f6cd312df69d30cf5bc9..b28b3b0465001178a40457acffc9aac7dff77719 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Eintrag bereits am %date% gespeichert'
             entry_saved: 'Eintag gespeichert'
+            # entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Eintrag aktualisiert'
             entry_reloaded: 'Eintrag neugeladen'
             entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen'
index 876e7900cf0c43cd4f09e08c98b1d02cf0833916..ec56055964b02d5d9c7d1f5fb92e0473c7afd7de 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Entry already saved on %date%'
             entry_saved: 'Entry saved'
+            entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Entry updated'
             entry_reloaded: 'Entry reloaded'
             entry_reload_failed: 'Failed to reload entry'
index e8461247c9c96b9104858dd0b04b90630c525f8b..11358d8e3351f1d82b9083979eeb776c021bb153 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Entrada ya guardada por %fecha%'
             entry_saved: 'Entrada guardada'
+            # entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Entrada actualizada'
             entry_reloaded: 'Entrada recargada'
             entry_reload_failed: 'Entrada recargada reprobada'
index d34ff8ff839735462bacfc0380d43e235c679c0b..92b4dabe12b56d51cf2fa86cae30448575222e00 100644 (file)
@@ -96,8 +96,8 @@ config:
         rule_label: 'قانون'
         tags_label: 'برچسب‌ها'
         faq:
-             title: 'پرسش‌های متداول'
-             tagging_rules_definition_title: 'برچسب‌گذاری خودکار یعنی چه؟'
+            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.'
         #     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> »'
@@ -383,30 +383,31 @@ developer:
 flashes:
     config:
         notice:
-           config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال می‌شود.'
-           password_updated: 'رمز به‌روز شد'
-           password_not_updated_demo: "در حالت نمایشی نمی‌توانید رمز کاربر را عوض کنید."
-           user_updated: 'اطلاعات به‌روز شد'
-           rss_updated: 'اطلاعات آر-اس-اس به‌روز شد'
-           tagging_rules_updated: 'برچسب‌گذاری خودکار به‌روز شد'
-           tagging_rules_deleted: 'قانون برچسب‌گذاری پاک شد'
-           user_added: 'کابر "%username%" افزوده شد'
-           rss_token_updated: 'کد آر-اس-اس به‌روز شد'
+            config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال می‌شود.'
+            password_updated: 'رمز به‌روز شد'
+            password_not_updated_demo: "در حالت نمایشی نمی‌توانید رمز کاربر را عوض کنید."
+            user_updated: 'اطلاعات به‌روز شد'
+            rss_updated: 'اطلاعات آر-اس-اس به‌روز شد'
+            tagging_rules_updated: 'برچسب‌گذاری خودکار به‌روز شد'
+            tagging_rules_deleted: 'قانون برچسب‌گذاری پاک شد'
+            user_added: 'کابر "%username%" افزوده شد'
+            rss_token_updated: 'کد آر-اس-اس به‌روز شد'
     entry:
         notice:
-           entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود'
-           entry_saved: 'مقاله ذخیره شد'
-           entry_updated: 'مقاله به‌روز شد'
-           entry_reloaded: 'مقاله به‌روز شد'
-           entry_reload_failed: 'به‌روزرسانی مقاله شکست خورد'
-           entry_archived: 'مقاله بایگانی شد'
-           entry_unarchived: 'مقاله از بایگانی درآمد'
-           entry_starred: 'مقاله برگزیده شد'
-           entry_unstarred: 'مقاله نابرگزیده شد'
-           entry_deleted: 'مقاله پاک شد'
+            entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود'
+            entry_saved: 'مقاله ذخیره شد'
+            # entry_saved_failed: 'Failed to save entry'
+            entry_updated: 'مقاله به‌روز شد'
+            entry_reloaded: 'مقاله به‌روز شد'
+            entry_reload_failed: 'به‌روزرسانی مقاله شکست خورد'
+            entry_archived: 'مقاله بایگانی شد'
+            entry_unarchived: 'مقاله از بایگانی درآمد'
+            entry_starred: 'مقاله برگزیده شد'
+            entry_unstarred: 'مقاله نابرگزیده شد'
+            entry_deleted: 'مقاله پاک شد'
     tag:
         notice:
-           tag_added: 'برچسب افزوده شد'
+            tag_added: 'برچسب افزوده شد'
     import:
         notice:
             failed: 'درون‌ریزی شکست خورد. لطفاً دوباره تلاش کنید.'
index 80ba0546a9e26fac01c4e1acd3de517ad9a8ab67..84e3a5fc3f38d35724a2293697c5abc126875e58 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Article déjà sauvergardé le %date%'
             entry_saved: 'Article enregistré'
+            entry_saved_failed: "L'enregistrement a échoué"
             entry_updated: 'Article mis à jour'
             entry_reloaded: 'Article rechargé'
             entry_reload_failed: "Le rechargement de l'article a échoué"
index 4f3ac090f95b8f4567de4bec0aaf54ba8be385d4..00ed9c98cd9ea280dc457aa661d9ab2921c624c8 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Contenuto già salvato in data %date%'
             entry_saved: 'Contenuto salvato'
+            # entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Contenuto aggiornato'
             entry_reloaded: 'Contenuto ricaricato'
             entry_reload_failed: 'Errore nel ricaricamento del contenuto'
index 46f58bbf5b0e4b9f4f32b76c00a6934a123c2a2f..70e4342c79f7e6703c44b96c440cb88bd84a5e00 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Article ja salvargardat lo %date%'
             entry_saved: 'Article enregistrat'
+            # entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Article mes a jorn'
             entry_reloaded: 'Article recargat'
             entry_reload_failed: "Fracàs de l'actualizacion de l'article"
index 292749ed68c6b980e27eef252265c7556ddf71f9..dd2dce5d933e2d834c758724e8ad70085d12f6a7 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Wpis już został dodany %date%'
             entry_saved: 'Wpis zapisany'
+            # entry_saved_failed: 'Failed to save entry'
             entry_updated: 'Wpis zaktualizowany'
             entry_reloaded: 'Wpis ponownie załadowany'
             entry_reload_failed: 'Błąd ponownego załadowania'
index 45040f3596e31ae5183560cf01337584d1fc9103..a3a09f4c17abdf4a66759673b48bce040e39c8b6 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             # entry_already_saved: 'Entry already saved on %date%'
             # entry_saved: 'Entry saved'
+            # entry_saved_failed: 'Failed to save entry'
             # entry_updated: 'Entry updated'
             # entry_reloaded: 'Entry reloaded'
             # entry_reload_failed: 'Failed to reload entry'
index 8a095a5b119fba0ffb30f3727a295e247ace9241..bc502a2b8131119faac42a61bf5df6c5c7cca6cc 100644 (file)
@@ -396,6 +396,7 @@ flashes:
         notice:
             entry_already_saved: 'Entry already saved on %date%'
             entry_saved: 'Makale kaydedildi'
+            # entry_saved_failed: 'Failed to save entry'
             # entry_updated: 'Entry updated'
             entry_reloaded: 'Makale içeriği yenilendi'
             # entry_reload_failed: 'Failed to reload entry'