fixed error code and improved error messages.

2002-05-27  Sven Neumann  <sven@gimp.org>

	* app/config/gimpconfig.c (gimp_config_serialize): fixed error code
	and improved error messages.
This commit is contained in:
Sven Neumann 2002-05-27 21:50:50 +00:00 committed by Sven Neumann
parent 799c772fe1
commit 93799415c8
3 changed files with 41 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2002-05-27 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig.c (gimp_config_serialize): fixed error code
and improved error messages.
2002-05-27 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpsizeentry.c (gimp_size_entry_attach_label):

View File

@ -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));

View File

@ -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));