* 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 static gboolean
show_parts (const char* path, MuConfig *opts) show_parts (const char* path, MuConfig *opts, GError **err)
{ {
MuMsg* msg; MuMsg* msg;
GError *err;
err = NULL; msg = mu_msg_new_from_file (path, NULL, err);
msg = mu_msg_new_from_file (path, NULL, &err); if (!msg)
if (!msg) {
if (err) {
g_warning ("error: %s", err->message);
g_error_free (err);
}
return FALSE; return FALSE;
}
g_print ("MIME-parts in this message:\n"); g_print ("MIME-parts in this message:\n");
@ -382,7 +375,7 @@ check_params (MuConfig *opts)
} }
MuError MuError
mu_cmd_extract (MuConfig *opts) mu_cmd_extract (MuConfig *opts, GError **err)
{ {
int rv; int rv;
@ -390,16 +383,20 @@ mu_cmd_extract (MuConfig *opts)
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_EXTRACT, g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_EXTRACT,
MU_ERROR_INTERNAL); 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; return MU_ERROR_IN_PARAMETERS;
}
if (!opts->params[2] && !opts->parts && if (!opts->params[2] && !opts->parts &&
!opts->save_attachments && !opts->save_all) !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 { else {
rv = mu_util_check_dir(opts->targetdir, FALSE, TRUE); rv = mu_util_check_dir(opts->targetdir, FALSE, TRUE);
if (!rv) 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); opts->targetdir);
else else
rv = save_parts (opts->params[1], rv = save_parts (opts->params[1],