Quick answer: Handle errors gracefully so they don't become crashes, fail safe and let players recover, validate inputs defensively, and capture errors so you can fix them. Good error handling turns crashes into recoverable hiccups.
Error handling determines whether an unexpected condition becomes a crash or a recoverable hiccup. Here are the best practices for error handling in games.
Handle Errors Gracefully So They Don't Become Crashes
An unhandled error becomes a crash, so handle errors gracefully where you can, catch and recover from conditions that would otherwise crash the game. Graceful handling turns many potential crashes into recoverable situations the player barely notices, which is the core value of error handling.
Bugnet captures errors and crashes, so you can see both what's handled and what crashes. Handling errors gracefully is the foundation, since an unhandled error is a crash, and graceful handling prevents many crashes from ever happening.
Fail Safe and Let Players Recover
When something does go wrong, fail safe, protect the player's progress and let them recover rather than losing their work or getting stuck. Failing safe means an error costs the player little, a recoverable hiccup rather than a catastrophe, which is much of what good error handling delivers.
Bugnet captures errors with context, so you can see when errors threaten player progress. Failing safe and letting players recover prevents errors from becoming catastrophic, by limiting the cost of any error to the player.
Validate Inputs Defensively and Capture Errors
Validate inputs and external data defensively rather than trusting them, since unexpected input is a common error source, and capture errors so you can see and fix them. Defensive validation prevents many errors, and capturing the rest gives you the visibility to fix what slips through.
Bugnet captures errors from the field with context, so you can see and fix what's going wrong. So practice error handling by handling errors gracefully, failing safe and letting players recover, and validating defensively while capturing errors, turning potential crashes into recoverable hiccups and surfacing problems for fixing.
Handle errors gracefully so they don't become crashes, fail safe and let players recover, validate inputs defensively, and capture errors so you can fix them. Good error handling turns crashes into recoverable hiccups.