Merge pull request #4630 from BrzVlad/feature-valloc-limit
[mono-project.git] / mono / utils / mono-error-internals.h
blob145aebfebd30c4b39225502e9c1980c61c9e16a9
1 /**
2 * \file
3 */
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*/
12 typedef struct {
13 unsigned short error_code;
14 unsigned short flags;
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;
22 union {
23 /* Valid if error_code != MONO_ERROR_EXCEPTION_INSTANCE.
24 * Used by type or field load errors and generic error specified by class.
26 MonoClass *klass;
27 /* Valid if error_code == MONO_ERROR_EXCEPTION_INSTANCE.
28 * Generic error specified by a managed instance.
30 uint32_t instance_handle;
31 } exn;
32 const char *full_message;
33 const char *full_message_with_fields;
34 const char *first_argument;
36 void *padding [3];
37 } MonoErrorInternal;
39 /* Invariant: the error strings are allocated in the mempool of the given image */
40 struct _MonoErrorBoxed {
41 MonoError error;
42 MonoImage *image;
45 #define error_init(error) do { \
46 ((MonoErrorInternal*)(error))->error_code = MONO_ERROR_NONE; \
47 ((MonoErrorInternal*)(error))->flags = 0; \
48 } while (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))) \
58 return (value);
60 void
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__);
65 void
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.*/
69 void
70 mono_error_set_error (MonoError *error, int error_code, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
72 void
73 mono_error_set_assembly_load (MonoError *error, const char *assembly_name, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
75 void
76 mono_error_set_assembly_load_simple (MonoError *error, const char *assembly_name, gboolean refection_only);
78 void
79 mono_error_set_type_load_class (MonoError *error, MonoClass *klass, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
81 void
82 mono_error_vset_type_load_class (MonoError *error, MonoClass *klass, const char *msg_format, va_list args);
84 void
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);
87 void
88 mono_error_set_method_load (MonoError *error, MonoClass *klass, const char *method_name, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
90 void
91 mono_error_set_field_load (MonoError *error, MonoClass *klass, const char *field_name, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(4,5);
93 void
94 mono_error_set_bad_image (MonoError *error, MonoImage *image, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
96 void
97 mono_error_set_bad_image_name (MonoError *error, const char *file_name, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
99 void
100 mono_error_set_out_of_memory (MonoError *error, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
102 void
103 mono_error_set_argument (MonoError *error, const char *argument, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
105 void
106 mono_error_set_argument_null (MonoError *oerror, const char *argument, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
108 void
109 mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(3,4);
111 void
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);
114 void
115 mono_error_set_execution_engine (MonoError *error, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
117 void
118 mono_error_set_not_implemented (MonoError *error, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
120 void
121 mono_error_set_not_supported (MonoError *error, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
123 void
124 mono_error_set_invalid_operation (MonoError *error, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
126 void
127 mono_error_set_exception_instance (MonoError *error, MonoException *exc);
129 void
130 mono_error_set_invalid_program (MonoError *oerror, const char *msg_format, ...) MONO_ATTR_FORMAT_PRINTF(2,3);
132 MonoException*
133 mono_error_prepare_exception (MonoError *error, MonoError *error_out);
135 MonoException*
136 mono_error_convert_to_exception (MonoError *error);
138 void
139 mono_error_raise_exception (MonoError *error);
141 void
142 mono_error_move (MonoError *dest, MonoError *src);
144 MonoErrorBoxed*
145 mono_error_box (const MonoError *error, MonoImage *image);
147 gboolean
148 mono_error_set_from_boxed (MonoError *error, const MonoErrorBoxed *from);
151 #endif