Tell me what’s wrong! – An XNA sample demonstrating exception handling and reporting in

Posted by George Clingerman on Geeks with Blogs See other posts from Geeks with Blogs or by George Clingerman
Published on Sun, 04 Apr 2010 01:45:36 GMT Indexed on 2010/04/04 1:53 UTC
Read the original article Hit count: 434

Filed under:

G360-1 I’ve always enjoyed using Nick Gravelyn’s exception handling in all of my games. You’re always going to encounter those unhandled exception that your players are going to ferret out and having a method to display them rather than just crashing to the dashboard is definitely more of an elegant solution. But the other day I got to thinking…what if we could do more? What if instead of just displaying the error, we could encourage the players to send us the error. So I started playing with that an expanding upon Nick’s sample code to see what I could come up with.

I got close to what I envisioned, but unfortunately there were some limitations to just what the XNA API could do. In my head I was picturing the players hitting “Send Message” and a 360 message would just be sent to the XBLIG developer. Unfortunately, you can only send messages in an XNA game to someone you’re currently in a network session with. Since I didn’t want to have a 360 server running all the time, virally connecting to players just to get error messages, I did the next best thing and just open up a 360 message and encourage them to manually enter the gamertag. Maybe someday we’ll be able to do that a little better, but this works for now.

In the sample, players can hit the “A” button or key to generate in an exception. If the debugger is not attached, then the Exception message screen will be shown explaining what has happened and giving the player a chance to send a 360 message to the gamertag provided or maybe even just send an email. Nick’s code has been changed just a bit. It now accepts any PlayerIndex (no longer hard coded to just PlayerIndex.One) and it no longer uses a MessageBox to get the users selection. The code has also been modified so that it works both for the 360 and for the PC.

Check out “Tell me what’s wrong!” and let me know if you have any thoughts or suggestions. I really do appreciate the feedback.

© Geeks with Blogs or respective owner