/* Module-specific contexts. */
ARRAY(union mail_index_module_context *) module_contexts;
- /* Last error returned by mail_index_get_error_message().
+ /* Last error returned by mail_index_get_last_error().
Cleared by mail_index_reset_error(). */
struct mail_index_error last_error;
/* Timestamp when mmap() failure was logged the last time. This is used
void mail_index_fsck_locked(struct mail_index *index);
/* Log an error and set it as the index's current error that is available
- with mail_index_get_error_message(). */
+ with mail_index_get_last_error(). */
void mail_index_set_error(struct mail_index *index, const char *fmt, ...)
ATTR_FORMAT(2, 3) ATTR_COLD;
void mail_index_set_error_code(struct mail_index *index,
}
}
-const char *mail_index_get_error_message(struct mail_index *index)
+const char *mail_index_get_last_error(struct mail_index *index,
+ enum mail_index_error_code *code_r)
{
+ if (code_r != NULL)
+ *code_r = index->last_error.code;
return index->last_error.text;
}
/* Returns the full error message for last error. This message may
contain paths etc. so it shouldn't be shown to users. */
-const char *mail_index_get_error_message(struct mail_index *index);
+const char *mail_index_get_last_error(struct mail_index *index,
+ enum mail_index_error_code *error_r);
/* Reset the error message. */
void mail_index_reset_error(struct mail_index *index);
e_debug(ctx->storage->event, "Cannot open mailbox index at %s: Not found", path);
} else if (rc < 0) {
e_debug(ctx->storage->event, "Cannot open mailbox index at %s: %s",
- path, mail_index_get_error_message(index));
+ path, mail_index_get_last_error(index, NULL));
}
mail_index_free(&index);
return ret;
mail_storage_set_internal_error(storage);
/* use the lib-index's error as our internal error string */
- index_error = mail_index_get_error_message(index);
+ index_error = mail_index_get_last_error(index, NULL);
if (index_error == NULL)
index_error = "BUG: Unknown internal index error";
storage->last_internal_error = i_strdup(index_error);
*error_r = t_strdup_printf(
"Couldn't commit mail index transaction for %s: %s",
box->vname,
- mail_index_get_error_message(box->view->index));
+ mail_index_get_last_error(box->view->index, NULL));
return -1;
}
/* getting the vsize now forces its recalculation */