Skip to content

Instantly share code, notes, and snippets.

@probablycorey
Created August 3, 2011 00:42
Show Gist options
  • Save probablycorey/1121630 to your computer and use it in GitHub Desktop.
Save probablycorey/1121630 to your computer and use it in GitHub Desktop.
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