Skip to content

Instantly share code, notes, and snippets.

@17cupsofcoffee
Created September 6, 2020 19:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 17cupsofcoffee/4d598f3b7e6fb6a63ae33f3b0badbfc3 to your computer and use it in GitHub Desktop.
Save 17cupsofcoffee/4d598f3b7e6fb6a63ae33f3b0badbfc3 to your computer and use it in GitHub Desktop.
Simple crash logging in Tetra
fn run() -> tetra::Result {
ContextBuilder::new("My Game", 1280, 720)
.build()?
.run(GameState::new)
}
fn report_crash(err: TetraError) {
let mut crash_log = File::create("./crash_log.txt").unwrap();
write!(
crash_log,
"Oh no! GAME_NAME has crashed. Here's the error message:\n\n\
{}\n\n\
If you don't know how to resolve this, please provide a bug report at ISSUE_URL.",
err
)
.unwrap();
}
fn main() {
run().unwrap_or_else(report_crash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment