changes after review

This commit is contained in:
Folkert 2023-10-20 16:14:09 +02:00
parent 793ab8ec16
commit eb61d352f5
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 36 additions and 25 deletions

View file

@ -202,12 +202,12 @@ impl<'a> ImportDispatcher for TestDispatcher<'a> {
self.wasi.dispatch(function_name, arguments, memory)
} else if module_name == "env" && function_name == "send_panic_msg_to_rust" {
let msg_ptr = arguments[0].expect_i32().unwrap();
let tag = arguments[1].expect_i32().unwrap();
let panic_tag = arguments[1].expect_i32().unwrap();
let roc_msg = RocStr::decode(memory, msg_ptr as _);
let msg = match tag {
0 => format!(r#"Roc failed with message: "{}""#, roc_msg),
1 => format!(r#"User crash with message: "{}""#, roc_msg),
tag => format!(r#"Got an invald panic tag: "{}""#, tag),
let msg = match panic_tag {
0 => format!(r#"Roc failed with message: "{roc_msg}""#),
1 => format!(r#"User crash with message: "{roc_msg}""#),
tag => format!(r#"Got an invald panic tag: "{panic_tag}""#),
};
panic!("{}", msg)
} else {

View file

@ -124,11 +124,11 @@ void roc_dealloc(void *ptr, unsigned int alignment)
//--------------------------
extern void send_panic_msg_to_rust(void* msg, uint32_t tag_id);
extern void send_panic_msg_to_rust(void* msg, uint32_t panic_tag);
void roc_panic(void* msg, unsigned int tag_id)
void roc_panic(void* msg, unsigned int panic_tag)
{
send_panic_msg_to_rust(msg, tag_id);
send_panic_msg_to_rust(msg, panic_tag);
exit(101);
}