forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathException.cpp
More file actions
53 lines (47 loc) · 1.55 KB
/
Exception.cpp
File metadata and controls
53 lines (47 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "utils/Exception.h"
#include "utils/StringUtils.h"
#include "il2cpp-object-internals.h"
struct Il2CppClass;
namespace il2cpp
{
namespace utils
{
std::string Exception::FormatException(const Il2CppException* ex)
{
#if RUNTIME_TINY
IL2CPP_ASSERT(0 && "Exceptions are not supported with the Tiny runtime");
return std::string();
#else
std::string exception_namespace = ex->klass->namespaze;
std::string exception_type = ex->klass->name;
if (ex->message)
return exception_namespace + "." + exception_type + ": " + il2cpp::utils::StringUtils::Utf16ToUtf8(il2cpp::utils::StringUtils::GetChars(ex->message));
else
return exception_namespace + "." + exception_type;
#endif
}
std::string Exception::FormatInvalidCastException(const Il2CppClass* fromType, const Il2CppClass* toType)
{
std::string message;
#if RUNTIME_TINY
IL2CPP_ASSERT(0 && "Exceptions are not supported with the Tiny runtime");
#else
if (fromType != NULL && toType != NULL)
{
message += "Unable to cast object of type '";
message += fromType->name;
message += "' to type '";
message += toType->name;
message += "'.";
}
#endif
return message;
}
std::string Exception::FormatStackTrace(const Il2CppException* ex)
{
if (ex->stack_trace)
return il2cpp::utils::StringUtils::Utf16ToUtf8(il2cpp::utils::StringUtils::GetChars(ex->stack_trace));
return "";
}
} // utils
} // il2cpp