* mu-cmd-extract: use GError for error reporting
This commit is contained in:
@ -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],
|
||||
|
||||
Reference in New Issue
Block a user