Merge pull request #4433 from kumpera/android-fixes
[mono.git] / mono / utils / mono-error.h
1 #ifndef __MONO_ERROR_H__
2 #define __MONO_ERROR_H__
3
4 #include <mono/utils/mono-publib.h>
5
6 enum {
7         /*
8         The supplied strings were dup'd by means of calling mono_error_dup_strings.
9         */
10         MONO_ERROR_FREE_STRINGS = 0x0001,
11
12         /*
13         Something happened while processing the error and the resulting message is incomplete.
14         */
15         MONO_ERROR_INCOMPLETE = 0x0002,
16         /*
17         This MonoError is heap allocated in a mempool
18         */
19         MONO_ERROR_MEMPOOL_BOXED = 0x0004
20 };
21
22 enum {
23         MONO_ERROR_NONE = 0,
24         MONO_ERROR_MISSING_METHOD = 1,
25         MONO_ERROR_MISSING_FIELD = 2,
26         MONO_ERROR_TYPE_LOAD = 3,
27         MONO_ERROR_FILE_NOT_FOUND = 4,
28         MONO_ERROR_BAD_IMAGE = 5,
29         MONO_ERROR_OUT_OF_MEMORY = 6,
30         MONO_ERROR_ARGUMENT = 7,
31         MONO_ERROR_ARGUMENT_NULL = 11,
32         MONO_ERROR_NOT_VERIFIABLE = 8,
33         MONO_ERROR_INVALID_PROGRAM = 12,
34
35         /*
36          * This is a generic error mechanism is you need to raise an arbitrary corlib exception.
37          * You must pass the exception name otherwise prepare_exception will fail with internal execution. 
38          */
39         MONO_ERROR_GENERIC = 9,
40         /* This one encapsulates a managed exception instance */
41         MONO_ERROR_EXCEPTION_INSTANCE = 10,
42
43         /* Not a valid error code - indicates that the error was cleaned up and reused */
44         MONO_ERROR_CLEANUP_CALLED_SENTINEL = 0xffff
45 };
46
47 /*Keep in sync with MonoErrorInternal*/
48 typedef struct _MonoError {
49         unsigned short error_code;
50     unsigned short hidden_0; /*DON'T TOUCH */
51
52         void *hidden_1 [12]; /*DON'T TOUCH */
53 } MonoError;
54
55 /* Mempool-allocated MonoError.*/
56 typedef struct _MonoErrorBoxed MonoErrorBoxed;
57
58 MONO_BEGIN_DECLS
59
60 MONO_RT_EXTERNAL_ONLY
61 MONO_API void
62 mono_error_init (MonoError *error);
63
64 MONO_API void
65 mono_error_init_flags (MonoError *error, unsigned short flags);
66
67 MONO_API void
68 mono_error_cleanup (MonoError *error);
69
70 MONO_API mono_bool
71 mono_error_ok (MonoError *error);
72
73 MONO_API unsigned short
74 mono_error_get_error_code (MonoError *error);
75
76 MONO_API const char*
77 mono_error_get_message (MonoError *error);
78
79 MONO_END_DECLS
80
81 #endif