From d81702ddd148abde32cbe2a45f6239e1baee6907 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 23 Oct 2017 12:01:27 +0300 Subject: [PATCH] quota: Improve error messages --- src/plugins/quota/quota-storage.c | 4 ++-- src/plugins/quota/quota.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index 95e794d576..0d27d74432 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -259,7 +259,7 @@ static int quota_check(struct mail_save_context *ctx, struct mailbox *src_box) return 0; case QUOTA_ALLOC_RESULT_TEMPFAIL: /* Log the error, but allow saving anyway. */ - i_error("quota check failed: %s", error); + i_error("quota: Failed to check if user is under quota: %s - saving mail anyway", error); return 0; default: quota_set_storage_error(qt, t->box->storage, ret, error); @@ -321,7 +321,7 @@ quota_save_begin(struct mail_save_context *ctx, struct istream *input) break; case QUOTA_ALLOC_RESULT_TEMPFAIL: /* Log the error, but allow saving anyway. */ - i_error("quota allocation failed: %s", error); + i_error("quota: Failed to check if user is under quota: %s - saving mail anyway", error); break; default: quota_set_storage_error(qt, t->box->storage, qret, error); diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 988328c615..7ef5e2514f 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -759,6 +759,7 @@ quota_get_resource(struct quota_root *root, const char *mailbox_name, const char *name, uint64_t *value_r, uint64_t *limit_r, const char **error_r) { + const char *error; uint64_t bytes_limit, count_limit; bool ignored, kilobytes = FALSE; int ret; @@ -772,17 +773,13 @@ quota_get_resource(struct quota_root *root, const char *mailbox_name, /* Get the value first. This call may also update quota limits if they're defined externally. */ - const char *error; - ret = root->backend.v.get_resource(root, name, value_r, &error); + ret = root->backend.v.get_resource(root, name, value_r, error_r); if (ret < 0) { - *error_r = t_strdup_printf( - "Could not get %s from quota backend for mailbox %s: %s", - name, mailbox_name, error); return QUOTA_GET_RESULT_INTERNAL_ERROR; } else if (ret == 0) { *error_r = t_strdup_printf( - "Requested resource %s for mailbox %s is unkown", - name, mailbox_name); + "Quota backend %s doesn't support requested resource %s", + root->backend.name, name); return QUOTA_GET_RESULT_UNKNOWN_RESOURCE; } @@ -790,7 +787,8 @@ quota_get_resource(struct quota_root *root, const char *mailbox_name, &bytes_limit, &count_limit, &ignored, &error) < 0) { *error_r = t_strdup_printf( - "Failed to get quota root rule limits: %s", error); + "Failed to get quota root rule limits for mailbox %s: %s", + mailbox_name, error); return QUOTA_GET_RESULT_INTERNAL_ERROR; }