diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-05-30 14:32:41 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-05-30 14:32:43 +0200 |
commit | 39ba51ca1af3085c3a7eb6dabdfae38c5034db1b (patch) | |
tree | fd804eba6b1ae213ce636a243955bcc485f427d1 | |
parent | 2c045a210ae786a9321f3cdb823ef778e772d733 (diff) | |
download | wallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.tar.gz wallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.tar.zst wallabag-39ba51ca1af3085c3a7eb6dabdfae38c5034db1b.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.
12 files changed, 45 insertions, 27 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 | } |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 8d392063..0c2a3249 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | # entry_already_saved: 'Entry already saved on %date%' | 397 | # entry_already_saved: 'Entry already saved on %date%' |
398 | # entry_saved: 'Entry saved' | 398 | # entry_saved: 'Entry saved' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | # entry_updated: 'Entry updated' | 400 | # entry_updated: 'Entry updated' |
400 | # entry_reloaded: 'Entry reloaded' | 401 | # entry_reloaded: 'Entry reloaded' |
401 | # entry_reload_failed: 'Failed to reload entry' | 402 | # entry_reload_failed: 'Failed to reload entry' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index c7a89492..b28b3b04 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' | 397 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' |
398 | entry_saved: 'Eintag gespeichert' | 398 | entry_saved: 'Eintag gespeichert' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Eintrag aktualisiert' | 400 | entry_updated: 'Eintrag aktualisiert' |
400 | entry_reloaded: 'Eintrag neugeladen' | 401 | entry_reloaded: 'Eintrag neugeladen' |
401 | entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen' | 402 | entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 876e7900..ec560559 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Entry already saved on %date%' | 397 | entry_already_saved: 'Entry already saved on %date%' |
398 | entry_saved: 'Entry saved' | 398 | entry_saved: 'Entry saved' |
399 | entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Entry updated' | 400 | entry_updated: 'Entry updated' |
400 | entry_reloaded: 'Entry reloaded' | 401 | entry_reloaded: 'Entry reloaded' |
401 | entry_reload_failed: 'Failed to reload entry' | 402 | entry_reload_failed: 'Failed to reload entry' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index e8461247..11358d8e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Entrada ya guardada por %fecha%' | 397 | entry_already_saved: 'Entrada ya guardada por %fecha%' |
398 | entry_saved: 'Entrada guardada' | 398 | entry_saved: 'Entrada guardada' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Entrada actualizada' | 400 | entry_updated: 'Entrada actualizada' |
400 | entry_reloaded: 'Entrada recargada' | 401 | entry_reloaded: 'Entrada recargada' |
401 | entry_reload_failed: 'Entrada recargada reprobada' | 402 | entry_reload_failed: 'Entrada recargada reprobada' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index d34ff8ff..92b4dabe 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -96,8 +96,8 @@ config: | |||
96 | rule_label: 'قانون' | 96 | rule_label: 'قانون' |
97 | tags_label: 'برچسبها' | 97 | tags_label: 'برچسبها' |
98 | faq: | 98 | faq: |
99 | title: 'پرسشهای متداول' | 99 | title: 'پرسشهای متداول' |
100 | tagging_rules_definition_title: 'برچسبگذاری خودکار یعنی چه؟' | 100 | tagging_rules_definition_title: 'برچسبگذاری خودکار یعنی چه؟' |
101 | # 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.' | 101 | # 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.' |
102 | # how_to_use_them_title: 'How do I use them?' | 102 | # how_to_use_them_title: 'How do I use them?' |
103 | # 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 <= 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 >= 5 AND domainName = "github.com"</i> » then tag as « <i>long reading, github </i> »' | 103 | # 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 <= 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 >= 5 AND domainName = "github.com"</i> » then tag as « <i>long reading, github </i> »' |
@@ -383,30 +383,31 @@ developer: | |||
383 | flashes: | 383 | flashes: |
384 | config: | 384 | config: |
385 | notice: | 385 | notice: |
386 | config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال میشود.' | 386 | config_saved: 'پیکربندی ذخیره شد. برخی از تنظیمات پس از این که قطع شدید اعمال میشود.' |
387 | password_updated: 'رمز بهروز شد' | 387 | password_updated: 'رمز بهروز شد' |
388 | password_not_updated_demo: "در حالت نمایشی نمیتوانید رمز کاربر را عوض کنید." | 388 | password_not_updated_demo: "در حالت نمایشی نمیتوانید رمز کاربر را عوض کنید." |
389 | user_updated: 'اطلاعات بهروز شد' | 389 | user_updated: 'اطلاعات بهروز شد' |
390 | rss_updated: 'اطلاعات آر-اس-اس بهروز شد' | 390 | rss_updated: 'اطلاعات آر-اس-اس بهروز شد' |
391 | tagging_rules_updated: 'برچسبگذاری خودکار بهروز شد' | 391 | tagging_rules_updated: 'برچسبگذاری خودکار بهروز شد' |
392 | tagging_rules_deleted: 'قانون برچسبگذاری پاک شد' | 392 | tagging_rules_deleted: 'قانون برچسبگذاری پاک شد' |
393 | user_added: 'کابر "%username%" افزوده شد' | 393 | user_added: 'کابر "%username%" افزوده شد' |
394 | rss_token_updated: 'کد آر-اس-اس بهروز شد' | 394 | rss_token_updated: 'کد آر-اس-اس بهروز شد' |
395 | entry: | 395 | entry: |
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' | 397 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' |
398 | entry_saved: 'مقاله ذخیره شد' | 398 | entry_saved: 'مقاله ذخیره شد' |
399 | entry_updated: 'مقاله بهروز شد' | 399 | # entry_saved_failed: 'Failed to save entry' |
400 | entry_reloaded: 'مقاله بهروز شد' | 400 | entry_updated: 'مقاله بهروز شد' |
401 | entry_reload_failed: 'بهروزرسانی مقاله شکست خورد' | 401 | entry_reloaded: 'مقاله بهروز شد' |
402 | entry_archived: 'مقاله بایگانی شد' | 402 | entry_reload_failed: 'بهروزرسانی مقاله شکست خورد' |
403 | entry_unarchived: 'مقاله از بایگانی درآمد' | 403 | entry_archived: 'مقاله بایگانی شد' |
404 | entry_starred: 'مقاله برگزیده شد' | 404 | entry_unarchived: 'مقاله از بایگانی درآمد' |
405 | entry_unstarred: 'مقاله نابرگزیده شد' | 405 | entry_starred: 'مقاله برگزیده شد' |
406 | entry_deleted: 'مقاله پاک شد' | 406 | entry_unstarred: 'مقاله نابرگزیده شد' |
407 | entry_deleted: 'مقاله پاک شد' | ||
407 | tag: | 408 | tag: |
408 | notice: | 409 | notice: |
409 | tag_added: 'برچسب افزوده شد' | 410 | tag_added: 'برچسب افزوده شد' |
410 | import: | 411 | import: |
411 | notice: | 412 | notice: |
412 | failed: 'درونریزی شکست خورد. لطفاً دوباره تلاش کنید.' | 413 | failed: 'درونریزی شکست خورد. لطفاً دوباره تلاش کنید.' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 80ba0546..84e3a5fc 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Article déjà sauvergardé le %date%' | 397 | entry_already_saved: 'Article déjà sauvergardé le %date%' |
398 | entry_saved: 'Article enregistré' | 398 | entry_saved: 'Article enregistré' |
399 | entry_saved_failed: "L'enregistrement a échoué" | ||
399 | entry_updated: 'Article mis à jour' | 400 | entry_updated: 'Article mis à jour' |
400 | entry_reloaded: 'Article rechargé' | 401 | entry_reloaded: 'Article rechargé' |
401 | entry_reload_failed: "Le rechargement de l'article a échoué" | 402 | entry_reload_failed: "Le rechargement de l'article a échoué" |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 4f3ac090..00ed9c98 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Contenuto già salvato in data %date%' | 397 | entry_already_saved: 'Contenuto già salvato in data %date%' |
398 | entry_saved: 'Contenuto salvato' | 398 | entry_saved: 'Contenuto salvato' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Contenuto aggiornato' | 400 | entry_updated: 'Contenuto aggiornato' |
400 | entry_reloaded: 'Contenuto ricaricato' | 401 | entry_reloaded: 'Contenuto ricaricato' |
401 | entry_reload_failed: 'Errore nel ricaricamento del contenuto' | 402 | entry_reload_failed: 'Errore nel ricaricamento del contenuto' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 46f58bbf..70e4342c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Article ja salvargardat lo %date%' | 397 | entry_already_saved: 'Article ja salvargardat lo %date%' |
398 | entry_saved: 'Article enregistrat' | 398 | entry_saved: 'Article enregistrat' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Article mes a jorn' | 400 | entry_updated: 'Article mes a jorn' |
400 | entry_reloaded: 'Article recargat' | 401 | entry_reloaded: 'Article recargat' |
401 | entry_reload_failed: "Fracàs de l'actualizacion de l'article" | 402 | entry_reload_failed: "Fracàs de l'actualizacion de l'article" |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 292749ed..dd2dce5d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Wpis już został dodany %date%' | 397 | entry_already_saved: 'Wpis już został dodany %date%' |
398 | entry_saved: 'Wpis zapisany' | 398 | entry_saved: 'Wpis zapisany' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | entry_updated: 'Wpis zaktualizowany' | 400 | entry_updated: 'Wpis zaktualizowany' |
400 | entry_reloaded: 'Wpis ponownie załadowany' | 401 | entry_reloaded: 'Wpis ponownie załadowany' |
401 | entry_reload_failed: 'Błąd ponownego załadowania' | 402 | entry_reload_failed: 'Błąd ponownego załadowania' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 45040f35..a3a09f4c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | # entry_already_saved: 'Entry already saved on %date%' | 397 | # entry_already_saved: 'Entry already saved on %date%' |
398 | # entry_saved: 'Entry saved' | 398 | # entry_saved: 'Entry saved' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | # entry_updated: 'Entry updated' | 400 | # entry_updated: 'Entry updated' |
400 | # entry_reloaded: 'Entry reloaded' | 401 | # entry_reloaded: 'Entry reloaded' |
401 | # entry_reload_failed: 'Failed to reload entry' | 402 | # entry_reload_failed: 'Failed to reload entry' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 8a095a5b..bc502a2b 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -396,6 +396,7 @@ flashes: | |||
396 | notice: | 396 | notice: |
397 | entry_already_saved: 'Entry already saved on %date%' | 397 | entry_already_saved: 'Entry already saved on %date%' |
398 | entry_saved: 'Makale kaydedildi' | 398 | entry_saved: 'Makale kaydedildi' |
399 | # entry_saved_failed: 'Failed to save entry' | ||
399 | # entry_updated: 'Entry updated' | 400 | # entry_updated: 'Entry updated' |
400 | entry_reloaded: 'Makale içeriği yenilendi' | 401 | entry_reloaded: 'Makale içeriği yenilendi' |
401 | # entry_reload_failed: 'Failed to reload entry' | 402 | # entry_reload_failed: 'Failed to reload entry' |