Skip to content

Commit

Permalink
Merge pull request #28 from eZioPan/make_array-err
Browse files Browse the repository at this point in the history
let "MakeArray" print item name on error
  • Loading branch information
Dirbaio authored Feb 25, 2024
2 parents 3875f77 + 26cb1f1 commit 0c421dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/transform/make_field_array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::bail;
use log::*;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -42,7 +43,7 @@ impl MakeFieldArray {
.any(|i| matches!(i.bit_offset, BitOffset::Cursed(_)));

if has_regular_bit_offset && has_cursed_bit_offset {
panic!("arrayize: items cannot mix bit_offset type")
bail!("arrayize: items {} cannot mix bit_offset type", to)
}
}

Expand All @@ -58,7 +59,7 @@ impl MakeFieldArray {
calc_array(items.iter().map(|x| x.bit_offset.min_offset()).collect());
if let Array::Cursed(_) = &array {
if !self.allow_cursed {
panic!("arrayize: items are not evenly spaced. Set `allow_cursed: true` to allow this.")
bail!("arrayize: items {} are not evenly spaced. Set `allow_cursed: true` to allow this.", to)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/transform/make_register_array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::bail;
use log::*;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -41,7 +42,7 @@ impl MakeRegisterArray {
let (offset, array) = calc_array(items.iter().map(|x| x.byte_offset).collect());
if let Array::Cursed(_) = &array {
if !self.allow_cursed {
panic!("arrayize: items are not evenly spaced. Set `allow_cursed: true` to allow this.")
bail!("arrayize: items {} are not evenly spaced. Set `allow_cursed: true` to allow this.", to);
}
}

Expand Down

0 comments on commit 0c421dc

Please sign in to comment.