[recipes] edit page: Improve error handling



commit 9dc73ee76014837e89107d30c34e5d5a70c3e038
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 14 16:01:56 2017 -0500

    edit page: Improve error handling
    
    We still want to reject recipes without a name.
    This broke when we separated IDs and names.

 src/gr-edit-page.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/gr-edit-page.c b/src/gr-edit-page.c
index 9b98aa5..acd010a 100644
--- a/src/gr-edit-page.c
+++ b/src/gr-edit-page.c
@@ -2186,6 +2186,11 @@ gr_edit_page_save (GrEditPage *page)
                               NULL);
                 ret = gr_recipe_store_update_recipe (store, page->recipe, old_id, &error);
         }
+        else if (name == NULL || name[0] == '\0') {
+                g_set_error (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                             _("You need to provide a name for the recipe"));
+                ret = FALSE;
+        }
         else {
                 g_autoptr(GrRecipe) recipe = NULL;
                 const char *author;
@@ -2215,12 +2220,9 @@ gr_edit_page_save (GrEditPage *page)
                 g_set_object (&page->recipe, recipe);
         }
 
-        if (!ret)
-                goto error;
-
-        return TRUE;
+        if (ret)
+          return TRUE;
 
-error:
         gtk_label_set_label (GTK_LABEL (page->error_label), error->message);
         gtk_revealer_set_reveal_child (GTK_REVEALER (page->error_revealer), TRUE);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]