moved default sories location and added some proper error handling

This commit is contained in:
2026-05-14 14:51:47 +01:00
parent e5a3d0d7b7
commit ba7985161e
9 changed files with 26 additions and 40 deletions
+20 -4
View File
@@ -25,12 +25,14 @@ pub async fn token_parse(
rx: &Receiver<(bool,usize)>,
) -> Result<(),String>
{
info!("DSL parsing begun");
let mut index: usize = 0;
if rx.recv().is_err()
{
warn!("Some issue with api");
// TOD eh?
};
info!("Client has connected");
// Run an infinite loop
'parse_loop: loop
{
@@ -43,7 +45,7 @@ pub async fn token_parse(
if token.starts_with('@')
{
let character_name: String = token.chars().skip(1).collect();
info!("Doing something with a character: {}", character_name);
debug!("Doing something with a character: {}", character_name);
// The index is incremented to after the character's instructions
index = match character_parse(index+1, tokens, character_name, &characters, &data_to_send).await
{
@@ -59,7 +61,7 @@ pub async fn token_parse(
"end" =>
{
info!("END command, exiting");
return Ok(()) // quit
return Ok(()) // quit successfully
},
"choice" =>
{
@@ -69,14 +71,28 @@ pub async fn token_parse(
Err(error) => return Err(error),
};
if rx.recv().is_err() { warn!("Error sending choices to client"); };
let (_, choice) = rx.recv().unwrap(); // TODO eh
let (_, choice) = match rx.recv()
{
Ok((_,choice)) => (None::<bool>, choice),
Err(err) =>
{
warn!("Error receiving choice from client, defaulting to choice 0 {}", err);
(None::<bool>, 0)
}
};
index = jump_points[choice];
info!("CHOICE command with {} choices", jump_points.len());
debug!("{:?} {} {}",jump_points, choice, index);
continue 'parse_loop
},
"or" =>
{
index += strings::closing_char(&tokens[index..], '{','}').unwrap(); // TODO eh
info!("OR command, jumping over");
index += match strings::closing_char(&tokens[index..], '{','}') // TODO eh
{
Ok(index) => index,
Err(_) => return Err(String::from("Unable to find closing brace to OR command")),
};
continue
},
"}" =>