Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libwild/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ blake3 = { workspace = true }
bumpalo-herd = { workspace = true }
bytemuck = { workspace = true }
bytesize = { workspace = true }
colored = { workspace = true }
colosseum = { workspace = true }
crossbeam-channel = { workspace = true }
crossbeam-queue = { workspace = true }
Expand Down
10 changes: 10 additions & 0 deletions libwild/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use colored::Colorize as _;
use std::fmt::Display;

pub type Result<T = (), E = Error> = core::result::Result<T, E>;
Expand Down Expand Up @@ -174,3 +175,12 @@ impl std::fmt::Debug for Error {
Ok(())
}
}

pub fn report_error(error: &Error) {
eprintln!("wild: {}: {error:?}", "error".red());
}

pub fn report_error_and_exit(error: &Error) -> ! {
report_error(error);
std::process::exit(-1);
}
5 changes: 1 addition & 4 deletions libwild/src/subprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ use std::ffi::c_void;
pub unsafe fn run_in_subprocess(args: &Args) -> ! {
let exit_code = match subprocess_result(args) {
Ok(code) => code,
Err(error) => {
eprintln!("Error: {error:?}");
-1
}
Err(error) => crate::error::report_error_and_exit(&error),
};
std::process::exit(exit_code);
}
Expand Down
8 changes: 7 additions & 1 deletion wild/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ static MIMALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;

fn main() -> libwild::error::Result {
fn main() {
if let Err(error) = run() {
libwild::error::report_error_and_exit(&error)
}
}

fn run() -> libwild::error::Result {
#[cfg(feature = "dhat")]
let _profiler = dhat::Profiler::new_heap();

Expand Down