Exception.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <stdint.h>
  3. #include "il2cpp-config.h"
  4. #include "utils/StringView.h"
  5. #include "il2cpp-class-internals.h"
  6. struct Il2CppException;
  7. struct Il2CppImage;
  8. struct Il2CppClass;
  9. namespace il2cpp
  10. {
  11. namespace vm
  12. {
  13. class TypeNameParseInfo;
  14. class LIBIL2CPP_CODEGEN_API Exception
  15. {
  16. // exported
  17. public:
  18. static Il2CppException* Get(il2cpp_hresult_t hresult, bool defaultToCOMException);
  19. static void PrepareExceptionForThrow(Il2CppException* ex, MethodInfo* lastManagedFrame = NULL);
  20. static NORETURN void Raise(Il2CppException* ex, MethodInfo* lastManagedFrame = NULL);
  21. static NORETURN void RaiseOutOfMemoryException();
  22. static NORETURN void RaiseOutOfMemoryException(const utils::StringView<Il2CppChar>& msg);
  23. static NORETURN void RaiseNullReferenceException();
  24. static NORETURN void RaiseNullReferenceException(const utils::StringView<Il2CppChar>& msg);
  25. static NORETURN void RaiseDivideByZeroException();
  26. static NORETURN void RaiseOverflowException();
  27. static NORETURN void RaiseArgumentOutOfRangeException(const char* msg);
  28. static NORETURN void Raise(il2cpp_hresult_t hresult, bool defaultToCOMException);
  29. inline static void RaiseIfFailed(il2cpp_hresult_t hresult, bool defaultToCOMException)
  30. {
  31. if (IL2CPP_HR_FAILED(hresult))
  32. Raise(hresult, defaultToCOMException);
  33. }
  34. ////TODO: rename to NewFromClassNameAndMessage
  35. static Il2CppException* FromNameMsg(const Il2CppImage* image, const char* name_space, const char* name, const char* msg);
  36. static Il2CppException* FromNameMsg(const Il2CppImage* image, const char* name_space, const char* name, const utils::StringView<Il2CppChar>& msg);
  37. static Il2CppException* FromNameMsg(const Il2CppImage* image, const char* name_space, const char* name, const utils::StringView<Il2CppChar>& msg, il2cpp_hresult_t hresult);
  38. public:
  39. ////TODO: rename all of these to NewXXX
  40. static Il2CppException* GetArgumentException(const char *arg, const char *msg);
  41. static Il2CppException* GetArgumentException(const utils::StringView<Il2CppChar>& arg, const utils::StringView<Il2CppChar>& msg);
  42. static Il2CppException* GetArgumentNullException(const char *arg);
  43. static Il2CppException* GetArgumentOutOfRangeException(const char *arg);
  44. static Il2CppException* GetTypeInitializationException(const char *msg, Il2CppException* innerException);
  45. static Il2CppException* GetIndexOutOfRangeException();
  46. static Il2CppException* GetIndexOutOfRangeException(const utils::StringView<Il2CppChar>& msg);
  47. static Il2CppException* GetNullReferenceException(const utils::StringView<Il2CppChar>& msg);
  48. static Il2CppException* GetInvalidCastException(const char* msg);
  49. static Il2CppException* GetInvalidCastException(const utils::StringView<Il2CppChar>& msg);
  50. static Il2CppException* GetTypeLoadException();
  51. static Il2CppException* GetTypeLoadException(const TypeNameParseInfo& typeNameParseInfo);
  52. static Il2CppException* GetTypeLoadException(const utils::StringView<char>& namespaze, const utils::StringView<char>& typeName, const utils::StringView<char>& assemblyName);
  53. static Il2CppException* GetTypeLoadExceptionForWindowsRuntimeType(const utils::StringView<char>& namespaze, const utils::StringView<char>& typeName);
  54. static Il2CppException* GetOutOfMemoryException(const utils::StringView<Il2CppChar>& msg);
  55. static Il2CppException* GetOverflowException();
  56. static Il2CppException* GetOverflowException(const char* msg);
  57. static Il2CppException* GetFormatException(const char* msg);
  58. static Il2CppException* GetSystemException();
  59. static Il2CppException* GetNotSupportedException(const char* msg);
  60. static Il2CppException* GetArrayTypeMismatchException();
  61. static Il2CppException* GetTypeLoadException(const char* msg);
  62. static Il2CppException* GetEntryPointNotFoundException(const char* msg);
  63. static Il2CppException* GetDllNotFoundException(const char* msg);
  64. static Il2CppException* GetInvalidOperationException(const char* msg);
  65. static Il2CppException* GetThreadInterruptedException();
  66. static Il2CppException* GetThreadAbortException();
  67. static Il2CppException* GetThreadStateException(const char* msg);
  68. static Il2CppException* GetSynchronizationLockException(const char* msg);
  69. static Il2CppException* GetMissingMethodException(const char* msg);
  70. static Il2CppException* GetMarshalDirectiveException(const char* msg);
  71. static Il2CppException* GetTargetException(const char* msg);
  72. static Il2CppException* GetExecutionEngineException(const char* msg);
  73. static Il2CppException* GetMethodAccessException(const char* msg);
  74. static Il2CppException* GetUnauthorizedAccessException(const utils::StringView<Il2CppChar>& msg);
  75. static Il2CppException* GetDivideByZeroException();
  76. static Il2CppException* GetPlatformNotSupportedException(const utils::StringView<Il2CppChar>& msg);
  77. static Il2CppException* GetFileLoadException(const char* msg);
  78. static Il2CppException* GetFileNotFoundException(const utils::StringView<Il2CppChar>& msg);
  79. static Il2CppException* GetMaxmimumNestedGenericsException();
  80. static void StoreExceptionInfo(Il2CppException* ex, Il2CppString* exceptionString);
  81. };
  82. } /* namespace vm */
  83. } /* namespace il2cpp */