mu: better error handling for opening database read-only

Be a bit clearer for the user.
This commit is contained in:
Dirk-Jan C. Binnema
2020-02-04 21:14:30 +02:00
parent 3fc2a5f3f8
commit 2575b2d0e3
4 changed files with 61 additions and 18 deletions

View File

@ -51,9 +51,13 @@ show_version (void)
static void
handle_error (MuConfig *conf, MuError merr, GError **err)
{
const char *path;
if (!(err && *err))
return;
path = mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB);
switch ((*err)->code) {
case MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK:
g_printerr ("maybe mu is already running?\n");
@ -71,6 +75,17 @@ handle_error (MuConfig *conf, MuError merr, GError **err)
g_printerr ("see the mu manpage for commands, or "
"'mu script' for the scripts\n");
break;
case MU_ERROR_XAPIAN_CANNOT_OPEN:
g_printerr("Failed to open database @ %s, \n"
"Please (re)build the database, i.e., with\n"
"\tmu index --rebuild\n", path);
return;
case MU_ERROR_XAPIAN_SCHEMA_MISMATCH:
g_printerr("Failed to open database @ %s, \n"
"because the schema version does not match mu's.\n\n"
"Please rebuild the database, i.e., with\n"
"\tmu index --rebuild\n", path);
return;
default:
break; /* nothing to do */
}