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