chore: replace panic! with internal_error!

This commit is contained in:
Luca Cervello 2022-10-11 11:52:08 +02:00
parent b3ab54ac90
commit c39103d6d0
No known key found for this signature in database
GPG key ID: 05180DD59F7580C4
8 changed files with 45 additions and 27 deletions

View file

@ -1,4 +1,5 @@
use inkwell::memory_buffer::MemoryBuffer;
use roc_error_macros::internal_error;
pub use roc_gen_llvm::llvm::build::FunctionIterator;
use roc_gen_llvm::llvm::build::{module_from_builtins, LlvmBackendMode};
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
@ -315,7 +316,7 @@ fn gen_from_mono_module_llvm(
// write the ll code to a file, so we can modify it
env.module.print_to_file(&app_ll_file).unwrap();
panic!(
internal_error!(
"😱 LLVM errors when defining module; I wrote the full LLVM IR to {:?}\n\n {}",
app_ll_file,
errors.to_string(),
@ -353,10 +354,10 @@ fn gen_from_mono_module_llvm(
Err(error) => {
use std::io::ErrorKind;
match error.kind() {
ErrorKind::NotFound => panic!(
ErrorKind::NotFound => internal_error!(
r"I could not find the `debugir` tool on the PATH, install it from https://github.com/vaivaswatha/debugir"
),
_ => panic!("{:?}", error),
_ => internal_error!("{:?}", error),
}
}
}
@ -417,7 +418,7 @@ fn gen_from_mono_module_llvm(
// module.print_to_file(app_ll_file);
module.write_bitcode_to_memory()
}
_ => panic!(
_ => internal_error!(
"TODO gracefully handle unsupported architecture: {:?}",
target.architecture
),
@ -506,14 +507,14 @@ fn gen_from_mono_module_dev_wasm32(
};
let host_bytes = std::fs::read(preprocessed_host_path).unwrap_or_else(|_| {
panic!(
internal_error!(
"Failed to read host object file {}! Try setting --prebuilt-platform=false",
preprocessed_host_path.display()
)
});
let host_module = roc_gen_wasm::parse_host(arena, &host_bytes).unwrap_or_else(|e| {
panic!(
internal_error!(
"I ran into a problem with the host object file, {} at offset 0x{:x}:\n{}",
preprocessed_host_path.display(),
e.offset,