少年修仙传客户端基础资源
hch
2024-04-11 4c71d74b77c9eb62a0323698c9a0db3b641a917e
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 IL2CPP_TINY_WITHOUT_DEBUGGER
        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 IL2CPP_TINY_WITHOUT_DEBUGGER
        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