5 #ifndef __MONO_ERROR_INTERNALS_H__
6 #define __MONO_ERROR_INTERNALS_H__
8 #include "mono/utils/mono-compiler.h"
9 #include "mono/metadata/class-internals.h"
11 /*Keep in sync with MonoError*/
13 unsigned short error_code
;
16 /*These name are suggestions of their content. MonoError internals might use them for something else.*/
17 const char *type_name
;
18 const char *assembly_name
;
19 const char *member_name
;
20 const char *exception_name_space
;
21 const char *exception_name
;
23 /* Valid if error_code != MONO_ERROR_EXCEPTION_INSTANCE.
24 * Used by type or field load errors and generic error specified by class.
27 /* Valid if error_code == MONO_ERROR_EXCEPTION_INSTANCE.
28 * Generic error specified by a managed instance.
30 uint32_t instance_handle
;
32 const char *full_message
;
33 const char *full_message_with_fields
;
34 const char *first_argument
;
39 /* Invariant: the error strings are allocated in the mempool of the given image */
40 struct _MonoErrorBoxed
{
45 #define error_init(error) do { \
46 ((MonoErrorInternal*)(error))->error_code = MONO_ERROR_NONE; \
47 ((MonoErrorInternal*)(error))->flags = 0; \
50 #define is_ok(error) ((error)->error_code == MONO_ERROR_NONE)
52 #define return_if_nok(error) do { if (!is_ok ((error))) return; } while (0)
53 #define return_val_if_nok(error,val) do { if (!is_ok ((error))) return (val); } while (0)
55 /* Only use this in icalls */
56 #define return_val_and_set_pending_if_nok(error,value) \
57 if (mono_error_set_pending_exception ((error))) \
61 mono_error_assert_ok_pos (MonoError
*error
, const char* filename
, int lineno
) MONO_LLVM_INTERNAL
;
63 #define mono_error_assert_ok(e) mono_error_assert_ok_pos (e, __FILE__, __LINE__);
66 mono_error_dup_strings (MonoError
*error
, gboolean dup_strings
);
68 /* This function is not very useful as you can't provide any details beyond the message.*/
70 mono_error_set_error (MonoError
*error
, int error_code
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
73 mono_error_set_assembly_load (MonoError
*error
, const char *assembly_name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
76 mono_error_set_assembly_load_simple (MonoError
*error
, const char *assembly_name
, gboolean refection_only
);
79 mono_error_set_type_load_class (MonoError
*error
, MonoClass
*klass
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
82 mono_error_vset_type_load_class (MonoError
*error
, MonoClass
*klass
, const char *msg_format
, va_list args
);
85 mono_error_set_type_load_name (MonoError
*error
, const char *type_name
, const char *assembly_name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
88 mono_error_set_method_load (MonoError
*error
, MonoClass
*klass
, const char *method_name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
91 mono_error_set_field_load (MonoError
*error
, MonoClass
*klass
, const char *field_name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
94 mono_error_set_bad_image (MonoError
*error
, MonoImage
*image
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
97 mono_error_set_bad_image_name (MonoError
*error
, const char *file_name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
100 mono_error_set_out_of_memory (MonoError
*error
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
103 mono_error_set_argument (MonoError
*error
, const char *argument
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
106 mono_error_set_argument_null (MonoError
*oerror
, const char *argument
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
109 mono_error_set_not_verifiable (MonoError
*oerror
, MonoMethod
*method
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
112 mono_error_set_generic_error (MonoError
*error
, const char * name_space
, const char *name
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
115 mono_error_set_execution_engine (MonoError
*error
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
118 mono_error_set_not_implemented (MonoError
*error
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
121 mono_error_set_not_supported (MonoError
*error
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
124 mono_error_set_invalid_operation (MonoError
*error
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
127 mono_error_set_exception_instance (MonoError
*error
, MonoException
*exc
);
130 mono_error_set_invalid_program (MonoError
*oerror
, const char *msg_format
, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
133 mono_error_prepare_exception (MonoError
*error
, MonoError
*error_out
);
136 mono_error_convert_to_exception (MonoError
*error
);
139 mono_error_raise_exception (MonoError
*error
);
142 mono_error_move (MonoError
*dest
, MonoError
*src
);
145 mono_error_box (const MonoError
*error
, MonoImage
*image
);
148 mono_error_set_from_boxed (MonoError
*error
, const MonoErrorBoxed
*from
);