Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nabetti1720 committed Nov 9, 2024
1 parent 58fc2b6 commit a2c47fb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions modules/llrt_assert/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ fn assert(ctx: Ctx, value: Value, message: Opt<Value>) -> Result<()> {
}

if let Some(obj) = message.0 {
if let Some(msg) = obj.as_string() {
let msg = msg.to_string().unwrap();
return Err(Exception::throw_message(&ctx, &msg));
}
if let Some(err) = obj.as_exception() {
return Err(err.clone().throw());
}
match obj.type_of() {
Type::String => {
let msg = obj.as_string().unwrap().to_string().unwrap();
return Err(Exception::throw_message(&ctx, &msg));
},
Type::Exception => return Err(obj.as_exception().cloned().unwrap().throw()),
_ => {},
};
}

Err(Exception::throw_message(
Expand Down

0 comments on commit a2c47fb

Please sign in to comment.