mono-error.h 2.5 KB

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