Created
September 6, 2020 19:10
-
-
Save 17cupsofcoffee/4d598f3b7e6fb6a63ae33f3b0badbfc3 to your computer and use it in GitHub Desktop.
Simple crash logging in Tetra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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