Mercurial > dovecot > original-hg > dovecot-1.2
diff src/plugins/lazy-expunge/lazy-expunge-plugin.c @ 5613:f717fb4b31c0 HEAD
Error handling rewrite.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 13 May 2007 20:10:48 +0300 |
parents | 74d3236313c1 |
children | ea9604a6cfd6 |
line wrap: on
line diff
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sun May 13 19:53:41 2007 +0300 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sun May 13 20:10:48 2007 +0300 @@ -69,7 +69,7 @@ mailbox_open_or_create(struct mail_storage *storage, const char *name) { struct mailbox *box; - bool temp; + enum mail_error error; box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST | MAILBOX_OPEN_KEEP_RECENT | @@ -77,11 +77,11 @@ if (box != NULL) return box; - (void)mail_storage_get_last_error(storage, &temp); - if (temp) + (void)mail_storage_get_last_error(storage, &error); + if (error != MAIL_ERROR_NOTFOUND) return NULL; - /* probably the mailbox just doesn't exist. try creating it. */ + /* try creating it. */ if (mail_storage_mailbox_create(storage, name, FALSE) < 0) return NULL; @@ -428,14 +428,16 @@ /* first do the normal sanity checks */ if (strcmp(name, "INBOX") == 0) { - mailbox_list_set_error(list, "INBOX can't be deleted."); + mailbox_list_set_error(list, MAIL_ERROR_NOTPOSSIBLE, + "INBOX can't be deleted."); return -1; } if (mailbox_list_get_mailbox_name_status(list, name, &status) < 0) return -1; if (status == MAILBOX_NAME_INVALID) { - mailbox_list_set_error(list, "Invalid mailbox name"); + mailbox_list_set_error(list, MAIL_ERROR_PARAMS, + "Invalid mailbox name"); return -1; } @@ -450,8 +452,8 @@ if ((ret = mailbox_move(list, name, dest_list, &destname)) < 0) return -1; if (ret == 0) { - mailbox_list_set_error(list, t_strdup_printf( - MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name)); + mailbox_list_set_error(list, MAIL_ERROR_NOTFOUND, + T_MAIL_ERR_MAILBOX_NOT_FOUND(name)); return -1; }