Skip to content

Commit

Permalink
refactor(actions): improve RLE decoding error handling
Browse files Browse the repository at this point in the history
- Add `DecodeRleError` variant to `ParseActionError` for specific RLE decoding errors
  • Loading branch information
ShenMian committed Jan 2, 2025
1 parent f691bb3 commit c02079e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl FromStr for Actions {
/// Creates a new `Actions` with LURD format string.
fn from_str(lurd: &str) -> Result<Self, Self::Err> {
if lurd.contains(char::is_numeric) {
return Actions::from_str(&rle_decode(lurd).unwrap());
return Actions::from_str(&rle_decode(lurd)?);
}
let mut instance = Actions::default();
for char in lurd.chars() {
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum ParseActionError {
/// Contains non-LURD format character.
#[error("invalid character: `{0}`")]
InvalidCharacter(char),
/// An error occurred during RLE decoding.
#[error(transparent)]
DecodeRleError(#[from] DecodeRleError),
}

/// An error which can be returned when encoding RLE.
Expand Down

0 comments on commit c02079e

Please sign in to comment.