This is great thanks. Is the idea to call it from an error handler? Or set up an unhandled exception handler and call it from there?