Skip to content

Commit bee2492

Browse files
Aidan63Aidan Lee
and
Aidan Lee
authored
Custom stack traces (#1220)
* print __customStack is present instead of __hx_dump_callstack * utf8_str instead of c_str * Prefix with _hx_ --------- Co-authored-by: Aidan Lee <[email protected]>
1 parent 00985d5 commit bee2492

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

include/hx/HxcppMain.h

+16-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,22 @@
9494
}
9595
catch (Dynamic e)
9696
{
97-
__hx_dump_stack();
98-
#ifdef HX_WIN_MAIN
99-
MessageBoxA(0, e==null() ? "null" : e->toString().__CStr(), "Error", 0);
100-
#else
101-
printf("Error : %s\n",e==null() ? "null" : e->toString().__CStr());
102-
#endif
103-
return -1;
97+
auto customStack = e->__Field(HX_CSTRING("_hx_customStack"), HX_PROP_DYNAMIC).asString();
98+
if (::hx::IsNotNull(customStack))
99+
{
100+
printf("%s\n", customStack.utf8_str());
101+
}
102+
else
103+
{
104+
__hx_dump_stack();
105+
}
106+
107+
#ifdef HX_WIN_MAIN
108+
MessageBoxA(0, e == null() ? "null" : e->toString().__CStr(), "Error", 0);
109+
#else
110+
printf("Error : %s\n", e == null() ? "null" : e->toString().__CStr());
111+
#endif
112+
return -1;
104113
}
105114
return 0;
106115
}

0 commit comments

Comments
 (0)