Skip to content

Commit a76a0fc

Browse files
Made it so the game doesnt crash if it cant get the latest version
I don't know how to test this but hopefully it won't crash anymore.
1 parent 9e40e95 commit a76a0fc

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/main.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{cell::Cell, collections::HashMap, rc::Rc};
33
use game::{loading::load_level, parsing::parse_level_download_response};
44
use macroquad::prelude::*;
55
use miniquad::conf::Icon;
6+
use ureq::http::Response;
67
use std::convert::TryInto;
78

89
use gr_rodio::rodio_raw::OutputStream;
@@ -488,13 +489,28 @@ async fn main() {
488489
println!("Getting latest version...");
489490
let version: &str = "1.1.2";
490491
let level_version: &str = "F-ALPHA";
491-
let latest_version: String = ureq::get(latest_version_url)
492+
let latest_version_result: Result<Response<ureq::Body>, ureq::Error> = ureq::get(latest_version_url)
492493
.query("fyre", "fyre")
493-
.call()
494-
.unwrap()
495-
.into_body()
496-
.read_to_string()
497-
.unwrap();
494+
.call();
495+
// .unwrap()
496+
// .into_body()
497+
// .read_to_string()
498+
// .unwrap();
499+
let mut latest_version: String = "".to_string();
500+
println!("{}", latest_version);
501+
502+
match latest_version_result {
503+
Ok(value) => {
504+
latest_version = value.into_body().read_to_string().unwrap();
505+
}
506+
507+
Err(error) => {
508+
latest_version = error.to_string();
509+
510+
println!("{}", latest_version);
511+
}
512+
}
513+
498514
println!("Preparing more values...");
499515
let default_level: &str = &format!(
500516
"version:{};song:./Resources/Music/main-level-songs/0.mp3;mode:1;cc_1001:0,0,0.392;cc_1002:0,0,0.392;;;x:400;y:480;rot:0;id:1",

0 commit comments

Comments
 (0)