1 #ifndef MAIL_ERROR_H 2 #define MAIL_ERROR_H 3 4 /* Some error strings that should be used everywhere to avoid 5 permissions checks from revealing mailbox's existence */ 6 #define MAIL_ERRSTR_MAILBOX_NOT_FOUND "Mailbox doesn't exist: %s" 7 #define MAIL_ERRSTR_NO_PERMISSION "Permission denied" 8 9 /* And just for making error strings consistent: */ 10 #define MAIL_ERRSTR_NO_QUOTA "Not enough disk quota" 11 #define MAIL_ERRSTR_LOCK_TIMEOUT "Timeout while waiting for lock" 12 13 /* Message to show to users when critical error occurs */ 14 #define MAIL_ERRSTR_CRITICAL_MSG \ 15 "Internal error occurred. Refer to server log for more information." 16 #define MAIL_ERRSTR_CRITICAL_MSG_STAMP \ 17 MAIL_ERRSTR_CRITICAL_MSG " [%Y-%m-%d %H:%M:%S]" 18 19 #define T_MAIL_ERR_MAILBOX_NOT_FOUND(name) \ 20 t_strdup_printf(MAIL_ERRSTR_MAILBOX_NOT_FOUND, name) 21 22 enum mail_error { 23 MAIL_ERROR_NONE = 0, 24 25 /* Temporary internal error */ 26 MAIL_ERROR_TEMP, 27 /* Temporary failure because a subsystem is down */ 28 MAIL_ERROR_UNAVAILABLE, 29 /* It's not possible to do the wanted operation */ 30 MAIL_ERROR_NOTPOSSIBLE, 31 /* Invalid parameters (eg. mailbox name not valid) */ 32 MAIL_ERROR_PARAMS, 33 /* No permission to do the request */ 34 MAIL_ERROR_PERM, 35 /* Out of disk quota for user */ 36 MAIL_ERROR_NOQUOTA, 37 /* Item (e.g. mailbox) doesn't exist or it's not visible to us */ 38 MAIL_ERROR_NOTFOUND, 39 /* Item (e.g. mailbox) already exists */ 40 MAIL_ERROR_EXISTS, 41 /* Tried to access an expunged message */ 42 MAIL_ERROR_EXPUNGED, 43 /* Operation cannot be done because another session prevents it 44 (e.g. lock timeout) */ 45 MAIL_ERROR_INUSE, 46 /* Can't do the requested data conversion (e.g. IMAP BINARY's 47 UNKNOWN-CTE code) */ 48 MAIL_ERROR_CONVERSION, 49 /* Can't do the requested data conversion because the original data 50 isn't valid. */ 51 MAIL_ERROR_INVALIDDATA, 52 /* Operation ran against some kind of a limit. */ 53 MAIL_ERROR_LIMIT, 54 /* Operation couldn't be finished as efficiently as required by 55 mail.lookup_abort. */ 56 MAIL_ERROR_LOOKUP_ABORTED, 57 }; 58 59 /* Convert errno to mail_error and an error string. Returns TRUE if successful, 60 FALSE if we couldn't handle the errno. */ 61 bool mail_error_from_errno(enum mail_error *error_r, 62 const char **error_string_r); 63 64 /* Build a helpful error message for a failed EACCES syscall. */ 65 const char *mail_error_eacces_msg(const char *func, const char *path); 66 /* Build a helpful error message for a failed EACCES syscall that tried to 67 write to directory (create, rename, etc). */ 68 const char *mail_error_create_eacces_msg(const char *func, const char *path); 69 70 #endif 71