for encoding error

This commit is contained in:
shenjack 2023-07-24 10:30:10 +08:00
parent 3629bcf163
commit c14786e216
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -592,7 +592,12 @@ pub mod ship {
impl RawShip {
#[inline]
pub fn from_file(path: String) -> Option<RawShip> {
let ship_file = fs::read_to_string(path).unwrap();
let ship_file = fs::read_to_string(path); // for encoding error
if let Err(e) = ship_file {
println!("ERROR!\n{:?}\n----------", e);
return None;
}
let ship_file = ship_file.unwrap();
let ship = from_str(&ship_file);
match ship {
Ok(ship) => Some(ship),