error setting fallback for incorrect goption callback hides problem
@chpe
Submitted by Christian Persch Link to original bug (#567496)
Description
In svn r7804, this code was added to goption.c:
retval = (* (GOptionArgFunc) entry->arg_data) (option_name, data, group->user_data, error);
- if (!retval && error != NULL && *error == NULL)
- g_set_error (error,
G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
_("Error parsing option %s"), option_name);
This however hides the problem (arg callback returning FALSE but not setting the GError) from the programmer. Currently we get a nice crash if the programmer does the usual
if (!g_option_context_parse (...., &error)) { g_printerr ("Error parsing: %s\n", error->message) }
due to the not-filled-in error.
Can we please at least add a g_warning in addition to the g_set_error() above, to alert the programmer to the problem?