aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-09-21 21:30:37 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-09-21 21:30:37 +0200
commit2156317958207e290a3f0679987a4f37e8f04b6c (patch)
treec781039c5ef3467d6fab8c16f753b79f7a189599
parent8ef674a027509b5f7d4c331ade7c0677e9b2eaca (diff)
downloadtools.nes-2156317958207e290a3f0679987a4f37e8f04b6c.tar.gz
tools.nes-2156317958207e290a3f0679987a4f37e8f04b6c.zip
nasm: prefer the use of die()
For historical reasons, some points of the code were not using this function, calling eprintln!() and exit() manually instead. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--crates/nasm/src/main.rs17
1 files changed, 5 insertions, 12 deletions
diff --git a/crates/nasm/src/main.rs b/crates/nasm/src/main.rs
index eea135e..8d3f35e 100644
--- a/crates/nasm/src/main.rs
+++ b/crates/nasm/src/main.rs
@@ -395,10 +395,7 @@ fn main() {
// Open the file and truncate it if it already exists.
let file = match File::create(&path) {
Ok(f) => f,
- Err(e) => {
- eprintln!("error: could not create '{name}.out': {e}");
- std::process::exit(1);
- }
+ Err(e) => die(format!("could not create '{name}.out': {e}")),
};
// And write the contents for this segment/file with
@@ -406,13 +403,11 @@ fn main() {
let mut writer = BufWriter::new(file);
for b in &segment.bundles {
if let Err(e) = writer.write_all(&b.bytes[..b.size as usize]) {
- eprintln!("error: could not write to '{name}.out': {e}");
- std::process::exit(1);
+ die(format!("could not write to '{name}.out': {e}"));
}
}
if let Err(e) = writer.flush() {
- eprintln!("error: could not write to '{name}.out': {e}");
- std::process::exit(1);
+ die(format!("could not write to '{name}.out': {e}"));
}
}
}
@@ -447,12 +442,10 @@ fn main() {
for b in res.bundles {
if let Err(e) = output.write_all(&b.bytes[..b.size as usize]) {
- eprintln!("error: could not write result in '{output_name}': {e}");
- std::process::exit(1);
+ die(format!("could not write result in '{output_name}': {e}"));
}
if let Err(e) = output.flush() {
- eprintln!("error: could not write to '{output_name}': {e}");
- std::process::exit(1);
+ die(format!("could not write to '{output_name}': {e}"));
}
}
}