* mu-cmd-extract: use GError for error reporting

This commit is contained in:
Dirk-Jan C. Binnema
2011-09-03 10:43:52 +03:00
parent 1b19938b5f
commit 59472fdce6

View File

@ -325,20 +325,13 @@ each_part_show (MuMsg *msg, MuMsgPart *part, gboolean color)
static gboolean
show_parts (const char* path, MuConfig *opts)
show_parts (const char* path, MuConfig *opts, GError **err)
{
MuMsg* msg;
GError *err;
err = NULL;
msg = mu_msg_new_from_file (path, NULL, &err);
if (!msg) {
if (err) {
g_warning ("error: %s", err->message);
g_error_free (err);
}
msg = mu_msg_new_from_file (path, NULL, err);
if (!msg)
return FALSE;
}
g_print ("MIME-parts in this message:\n");
@ -382,7 +375,7 @@ check_params (MuConfig *opts)
}
MuError
mu_cmd_extract (MuConfig *opts)
mu_cmd_extract (MuConfig *opts, GError **err)
{
int rv;
@ -390,16 +383,20 @@ mu_cmd_extract (MuConfig *opts)
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_EXTRACT,
MU_ERROR_INTERNAL);
if (!check_params (opts))
if (!check_params (opts)) {
g_set_error (err, 0, MU_ERROR_IN_PARAMETERS,
"error in parameters");
return MU_ERROR_IN_PARAMETERS;
}
if (!opts->params[2] && !opts->parts &&
!opts->save_attachments && !opts->save_all)
rv = show_parts (opts->params[1], opts); /* show, don't save */
rv = show_parts (opts->params[1], opts, err); /* show, don't save */
else {
rv = mu_util_check_dir(opts->targetdir, FALSE, TRUE);
if (!rv)
g_warning ("target '%s' is not a writable directory",
g_set_error (err, 0, MU_ERROR_FILE_CANNOT_WRITE,
"target '%s' is not a writable directory",
opts->targetdir);
else
rv = save_parts (opts->params[1],