* make error messages more consistent

This commit is contained in:
Dirk-Jan C. Binnema 2010-11-30 09:02:29 +02:00
parent 00bd5e1c87
commit 2b393ed7c5
7 changed files with 36 additions and 26 deletions

View File

@ -17,7 +17,7 @@
**
*/
#ifdef HAVE_CONFIG_H
#if HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
@ -84,7 +84,8 @@ save_part_if (MuMsgPart *part, SaveData *sd)
* the attachment check may be a bit too strict */
if (sd->attachments_only)
if (!part->disposition ||
((g_ascii_strcasecmp (part->disposition, "attachment") != 0) &&
((g_ascii_strcasecmp (part->disposition,
"attachment") != 0) &&
g_ascii_strcasecmp (part->disposition, "inline")))
return;
@ -103,8 +104,8 @@ save_part_if (MuMsgPart *part, SaveData *sd)
}
static gboolean
save_certain_parts (MuMsg *msg, gboolean attachments_only, const gchar *targetdir,
gboolean overwrite)
save_certain_parts (MuMsg *msg, gboolean attachments_only,
const gchar *targetdir, gboolean overwrite)
{
SaveData sd;
@ -204,17 +205,19 @@ static gboolean
check_params (MuConfigOptions *opts)
{
if (!opts->params[1]) {
g_warning ("missing mail file to extract something from");
g_warning ("usage: mu extract [options] <file>");
return FALSE;
}
if (!mu_util_check_dir(opts->targetdir, FALSE, TRUE)) {
g_warning ("target '%s' is not a writable directory", opts->targetdir);
g_warning ("target '%s' is not a writable directory",
opts->targetdir);
return FALSE;
}
if (opts->save_attachments && opts->save_all) {
g_warning ("only one of --save-attachments and --save-all is allowed");
g_warning ("only one of --save-attachments and"
" --save-all is allowed");
return FALSE;
}

View File

@ -64,7 +64,7 @@ print_xapian_query (MuQuery *xapian, const gchar *query)
err = NULL;
querystr = mu_query_as_string (xapian, query, &err);
if (!querystr) {
g_warning ("Error: %s", err->message);
g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}
@ -156,7 +156,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfigOptions *opts)
iter = mu_query_run (xapian, query, sortid,
opts->descending ? FALSE : TRUE, 0, &err);
if (!iter) {
g_warning ("Error: %s", err->message);
g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}
@ -169,7 +169,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfigOptions *opts)
opts->summary_len);
if (matches == 0)
g_printerr ("No matches found\n");
g_warning ("No matches found");
mu_msg_iter_destroy (iter);
@ -184,7 +184,7 @@ query_params_valid (MuConfigOptions *opts)
if (opts->linksdir)
if (opts->xquery) {
g_printerr ("Invalid option for '--linksdir'\n");
g_warning ("invalid option for --linksdir");
return FALSE;
}
@ -209,13 +209,13 @@ resolve_bookmark (MuConfigOptions *opts)
bmfile = mu_runtime_bookmarks_file();
bm = mu_bookmarks_new (bmfile);
if (!bm) {
g_warning ("Failed to open bookmarks file '%s'", bmfile);
g_warning ("failed to open bookmarks file '%s'", bmfile);
return FALSE;
}
val = (gchar*)mu_bookmarks_lookup (bm, opts->bookmark);
if (!val)
g_warning ("Bookmark '%s' not found", opts->bookmark);
g_warning ("bookmark '%s' not found", opts->bookmark);
else
val = g_strdup (val);
@ -232,7 +232,7 @@ get_query (MuConfigOptions *opts)
/* params[0] is 'find', actual search params start with [1] */
if (!opts->bookmark && !opts->params[1]) {
g_warning ("Empty search query");
g_warning ("usage: mu find [options] search-expression");
return FALSE;
}
@ -260,7 +260,7 @@ static gboolean
db_is_ready (const char *xpath)
{
if (mu_util_db_is_empty (xpath)) {
g_warning ("Database is empty; use 'mu index' to "
g_warning ("database is empty; use 'mu index' to "
"add messages");
return FALSE;
}
@ -301,7 +301,7 @@ mu_cmd_find (MuConfigOptions *opts)
err = NULL;
xapian = mu_query_new (xpath, &err);
if (!xapian) {
g_warning ("Error: %s", err->message);
g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}

View File

@ -78,8 +78,15 @@ install_sig_handler (void)
static gboolean
check_index_params (MuConfigOptions *opts)
check_index_or_cleanup_params (MuConfigOptions *opts)
{
/* param[0] == 'index' or 'cleanup', there should be no
* param[1] */
if (opts->params[1]) {
g_warning ("usage: mu %s [options]", opts->params[0]);
return FALSE;
}
if (opts->linksdir || opts->xquery) {
g_warning ("invalid option(s) for command");
return FALSE;
@ -223,10 +230,10 @@ cmd_index (MuIndex *midx, MuConfigOptions *opts, MuIndexStats *stats,
g_message ("Indexing messages under %s [%s]", opts->maildir,
mu_runtime_xapian_dir());
t = time (NULL);
rv = mu_index_run (midx, opts->maildir, opts->reindex, stats,
show_progress ? index_msg_cb : index_msg_silent_cb,
show_progress ? index_msg_cb:index_msg_silent_cb,
NULL, NULL);
if (!opts->quiet) {
@ -241,7 +248,8 @@ cmd_index (MuIndex *midx, MuConfigOptions *opts, MuIndexStats *stats,
}
if (rv == MU_OK || rv == MU_STOP) {
MU_WRITE_LOG ("processed: %u; updated/new: %u, cleaned-up: %u",
MU_WRITE_LOG ("processed: %u; updated/new: %u, "
"cleaned-up: %u",
stats->_processed, stats->_updated,
stats->_cleaned_up);
return TRUE;
@ -265,7 +273,7 @@ cmd_index_or_cleanup (MuConfigOptions *opts)
g_return_val_if_fail (mu_cmd_equals (opts, "index") ||
mu_cmd_equals (opts, "cleanup"), FALSE);
if (!check_index_params (opts) ||
if (!check_index_or_cleanup_params (opts) ||
!database_version_check_and_update(opts))
return FALSE;

View File

@ -39,9 +39,9 @@ mu_cmd_mkdir (MuConfigOptions *opts)
g_return_val_if_fail (mu_cmd_equals (opts, "mkdir"), FALSE);
if (!opts->params[1]) {
g_printerr (
g_warning (
"usage: mu mkdir [-u,--mode=<mode>] "
"<dir> [more dirs]\n");
"<dir> [more dirs]");
return FALSE;
}

View File

@ -73,7 +73,7 @@ mu_cmd_view (MuConfigOptions *opts)
/* note: params[0] will be 'view' */
if (!opts->params[0] || !opts->params[1]) {
g_printerr ("Missing files to view\n");
g_warning ("usage: mu view [options] <file> [<files>]");
return FALSE;
}

View File

@ -256,7 +256,7 @@ parse_params (MuConfigOptions *opts, int *argcp, char ***argvp)
err = NULL;
rv = g_option_context_parse (context, argcp, argvp, &err);
if (!rv) {
g_printerr ("error in options: %s\n", err->message);
g_warning ("error in options: %s\n", err->message);
g_error_free (err);
}

View File

@ -81,7 +81,6 @@ mu_str_normalize_in_place (char *str, gboolean downcase)
case 0x89:
case 0x8a:
case 0x8b:
g_printerr ("<%c>", downcase ? 'e' : 'E');
str[i++] = downcase ? 'e' : 'E';
break;