From 93799415c8e0f49a7f50693fcdde4e939239a400 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 27 May 2002 21:50:50 +0000 Subject: [PATCH] fixed error code and improved error messages. 2002-05-27 Sven Neumann * app/config/gimpconfig.c (gimp_config_serialize): fixed error code and improved error messages. --- ChangeLog | 5 +++++ app/config/gimpconfig.c | 24 ++++++++++++++++++------ libgimpconfig/gimpconfig-iface.c | 24 ++++++++++++++++++------ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 43d7ff22cd..bbed0c5272 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-05-27 Sven Neumann + + * app/config/gimpconfig.c (gimp_config_serialize): fixed error code + and improved error messages. + 2002-05-27 Michael Natterer * libgimpwidgets/gimpsizeentry.c (gimp_size_entry_attach_label): diff --git a/app/config/gimpconfig.c b/app/config/gimpconfig.c index f8eb7e9726..783b6c98f8 100644 --- a/app/config/gimpconfig.c +++ b/app/config/gimpconfig.c @@ -213,7 +213,7 @@ gimp_config_serialize (GObject *object, if (fd == -1) { g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_OPEN, + GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, _("Failed to create temporary file for '%s': %s"), filename, g_strerror (errno)); g_free (tmpname); @@ -234,10 +234,22 @@ gimp_config_serialize (GObject *object, if (! success) { - g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, - _("Error when writing to file '%s': %s"), - tmpname, g_strerror (errno)); + gchar *msg; + + if (g_file_test (filename, G_FILE_TEST_EXIST)) + { + msg = g_strdup_printf (_("Error when writing to temporary file for '%s': %s\n" + "The original file has not been touched."), + filename, g_strerror (errno)); + } + else + { + msg = g_strdup_printf (_("Error when writing to temporary file for '%s': %s\n" + "No file has been created."), + filename, g_strerror (errno)); + } + + g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, msg); unlink (tmpname); } @@ -247,7 +259,7 @@ gimp_config_serialize (GObject *object, if (success && rename (tmpname, filename) == -1) { g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_OPEN, + GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, _("Failed to create file '%s': %s"), filename, g_strerror (errno)); diff --git a/libgimpconfig/gimpconfig-iface.c b/libgimpconfig/gimpconfig-iface.c index f8eb7e9726..783b6c98f8 100644 --- a/libgimpconfig/gimpconfig-iface.c +++ b/libgimpconfig/gimpconfig-iface.c @@ -213,7 +213,7 @@ gimp_config_serialize (GObject *object, if (fd == -1) { g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_OPEN, + GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, _("Failed to create temporary file for '%s': %s"), filename, g_strerror (errno)); g_free (tmpname); @@ -234,10 +234,22 @@ gimp_config_serialize (GObject *object, if (! success) { - g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, - _("Error when writing to file '%s': %s"), - tmpname, g_strerror (errno)); + gchar *msg; + + if (g_file_test (filename, G_FILE_TEST_EXIST)) + { + msg = g_strdup_printf (_("Error when writing to temporary file for '%s': %s\n" + "The original file has not been touched."), + filename, g_strerror (errno)); + } + else + { + msg = g_strdup_printf (_("Error when writing to temporary file for '%s': %s\n" + "No file has been created."), + filename, g_strerror (errno)); + } + + g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, msg); unlink (tmpname); } @@ -247,7 +259,7 @@ gimp_config_serialize (GObject *object, if (success && rename (tmpname, filename) == -1) { g_set_error (error, - GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_OPEN, + GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE, _("Failed to create file '%s': %s"), filename, g_strerror (errno));