Created
August 3, 2011 00:42
-
-
Save probablycorey/1121630 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void uncaughtExceptionHandler(NSException *e) { | |
NSLog(@"ERROR: Uncaught exception %@", [e description]); | |
lua_State *L = wax_currentLuaState(); | |
if (L) { | |
wax_getStackTrace(L); | |
const char *stackTrace = luaL_checkstring(L, -1); | |
NSLog(@"%s", stackTrace); | |
NSString *message = [NSString stringWithFormat:@"Unexpected Exception:\n---------------------\n%@\n%s", [e description], stackTrace]; | |
Class CrashReporter = NSClassFromString(@"CrashReporter"); | |
[CrashReporter crash:message]; | |
lua_pop(L, -1); // remove the stackTrace | |
} | |
} | |
int wax_panic(lua_State *L) { | |
printf("Lua panicked and quit:\n---------------------\n%s\n", luaL_checkstring(L, -1)); | |
NSString *message = [NSString stringWithUTF8String:luaL_checkstring(L, -1)]; | |
Class CrashReporter = NSClassFromString(@"CrashReporter"); | |
[CrashReporter crash:message]; | |
exit(EXIT_FAILURE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment