mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
ruby: fetch class name in case of error
There is not much point in complicating the code for error messages that can be easily constructed. Before: database closed (RuntimeError) After: Notmuch::Database object destroyed (RuntimeError) Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
parent
78c059a24c
commit
79bb82c217
1 changed files with 16 additions and 14 deletions
|
@ -55,39 +55,41 @@ extern ID ID_db_mode;
|
||||||
# define RSTRING_PTR(v) (RSTRING((v))->ptr)
|
# define RSTRING_PTR(v) (RSTRING((v))->ptr)
|
||||||
#endif /* !defined (RSTRING_PTR) */
|
#endif /* !defined (RSTRING_PTR) */
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Object(obj, message, ptr) \
|
#define Data_Get_Notmuch_Object(obj, ptr) \
|
||||||
do { \
|
do { \
|
||||||
(ptr) = rb_data_object_get ((obj)); \
|
(ptr) = rb_data_object_get ((obj)); \
|
||||||
if (!(ptr)) \
|
if (!(ptr)) { \
|
||||||
rb_raise (rb_eRuntimeError, (message)); \
|
VALUE cname = rb_class_name (CLASS_OF ((obj))); \
|
||||||
|
rb_raise (rb_eRuntimeError, "%"PRIsVALUE" object destroyed", cname); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Database(obj, ptr) \
|
#define Data_Get_Notmuch_Database(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "database closed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Directory(obj, ptr) \
|
#define Data_Get_Notmuch_Directory(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "directory destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_FileNames(obj, ptr) \
|
#define Data_Get_Notmuch_FileNames(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "filenames destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Query(obj, ptr) \
|
#define Data_Get_Notmuch_Query(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "query destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Threads(obj, ptr) \
|
#define Data_Get_Notmuch_Threads(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "threads destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Messages(obj, ptr) \
|
#define Data_Get_Notmuch_Messages(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "messages destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Thread(obj, ptr) \
|
#define Data_Get_Notmuch_Thread(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "thread destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Message(obj, ptr) \
|
#define Data_Get_Notmuch_Message(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "message destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
#define Data_Get_Notmuch_Tags(obj, ptr) \
|
#define Data_Get_Notmuch_Tags(obj, ptr) \
|
||||||
Data_Get_Notmuch_Object ((obj), "tags destroyed", (ptr))
|
Data_Get_Notmuch_Object ((obj), (ptr))
|
||||||
|
|
||||||
/* status.c */
|
/* status.c */
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue