]> git.notmuchmail.org Git - notmuch/blob - bindings/ruby/status.c
3d106ca9efd76e20ed5db88e50b4031918f01895
[notmuch] / bindings / ruby / status.c
1 /* The Ruby interface to the notmuch mail library
2  *
3  * Copyright © 2010 Ali Polatel
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see http://www.gnu.org/licenses/ .
17  *
18  * Author: Ali Polatel <alip@exherbo.org>
19  */
20
21 #include "defs.h"
22
23 void
24 notmuch_rb_status_raise(notmuch_status_t status)
25 {
26     switch (status) {
27     case NOTMUCH_STATUS_SUCCESS:
28     case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
29         break;
30     case NOTMUCH_STATUS_OUT_OF_MEMORY:
31         rb_raise(notmuch_rb_eMemoryError, "out of memory");
32     case NOTMUCH_STATUS_READ_ONLY_DATABASE:
33         rb_raise(notmuch_rb_eReadOnlyError, "read-only database");
34     case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
35         rb_raise(notmuch_rb_eXapianError, "xapian exception");
36     case NOTMUCH_STATUS_FILE_ERROR:
37         rb_raise(notmuch_rb_eFileError, "failed to read/write file");
38     case NOTMUCH_STATUS_FILE_NOT_EMAIL:
39         rb_raise(notmuch_rb_eFileNotEmailError, "file not email");
40     case NOTMUCH_STATUS_NULL_POINTER:
41         rb_raise(notmuch_rb_eNullPointerError, "null pointer");
42     case NOTMUCH_STATUS_TAG_TOO_LONG:
43         rb_raise(notmuch_rb_eTagTooLongError, "tag too long");
44     case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
45         rb_raise(notmuch_rb_eUnbalancedFreezeThawError, "unbalanced freeze/thaw");
46     default:
47         rb_raise(notmuch_rb_eBaseError, "unknown notmuch error");
48     }
49 }