From b3b7b2e57f2ace90dc1643dd0fc8939bb286b413 Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 4 Jul 2025 10:40:45 -0400 Subject: [PATCH] Address two of "warning: function call inside of `expect`" --- src/bin/kawari-world.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index ad0a94e..0400583 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -537,9 +537,10 @@ async fn client_loop( let connection_data = scope .create_userdata_ref_mut(&mut lua_player)?; + /* TODO: Instead of panicking we ought to send a message to the player + * and the console log, and abandon execution. */ lua.load( - std::fs::read(&file_name) - .expect(format!("Failed to load script file {}!", &file_name).as_str()), + std::fs::read(&file_name).unwrap_or_else(|_| panic!("Failed to load script file {}!", &file_name)), ) .set_name("@".to_string() + &file_name) .exec()?; @@ -643,10 +644,10 @@ async fn client_loop( lua.scope(|scope| { let connection_data = scope .create_userdata_ref_mut(&mut lua_player)?; - + /* TODO: Instead of panicking we ought to send a message to the player + * and the console log, and abandon execution. */ lua.load( - std::fs::read(&file_name) - .expect(format!("Failed to load script file {}!", &file_name).as_str()), + std::fs::read(&file_name).unwrap_or_else(|_| panic!("Failed to load script file {}!", &file_name)), ) .set_name("@".to_string() + &file_name) .exec()?;