lib: improve error handling, cleanups

This commit is contained in:
Dirk-Jan C. Binnema 2020-10-31 09:43:52 +02:00
parent aea64c4a08
commit 69b157a346
4 changed files with 10 additions and 8 deletions

View File

@ -305,13 +305,19 @@ get_num_field (MuMsg *self, MuMsgFieldId mfid)
const char*
mu_msg_get_header (MuMsg *self, const char *header)
{
GError *err;
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (header, NULL);
/* if we don't have a file object yet, we need to
* create it from the file on disk */
if (!mu_msg_load_msg_file (self, NULL))
return NULL;
err = NULL;
if (!mu_msg_load_msg_file (self, &err)) {
g_warning ("failed to load message file: %s",
err ? err->message : "something went wrong");
return NULL;
}
return free_later_str
(self, mu_msg_file_get_header (self->_file, header));

View File

@ -482,9 +482,6 @@ mu_query_count_run (MuQuery *self, const char *searchexpr) try
} MU_XAPIAN_CATCH_BLOCK_RETURN (0);
char*
mu_query_internal_xapian (MuQuery *self, const char *searchexpr, GError **err)
{

View File

@ -30,7 +30,7 @@ namespace Mu {
struct Error final: public std::exception {
enum struct Code {
AccessDenied,
AccessDenied = 100, // don't overlap with MuError
Command,
File,
Index,
@ -127,7 +127,6 @@ struct Error final: public std::exception {
private:
const Code code_;
std::string what_;
};

View File

@ -21,7 +21,7 @@
namespace Mu {
/**
* Setup readline when available & on tty.
* Setup readline when available and on tty.
*
* @param histpath path to the history file
* @param max_lines maximum number of history to save