Clean up error handling

This commit is contained in:
Jaby
2022-11-27 22:32:14 +01:00
parent 1e1c514ca4
commit 726d85f4ed
3 changed files with 10 additions and 27 deletions

View File

@@ -34,13 +34,13 @@ impl IndexedImage {
png::BitDepth::Four => IndexPerByte::TwoIndices,
png::BitDepth::Eight => IndexPerByte::OneIndex,
_ => {
return Err(Error::from_str("Only 4 and 8bit color depth are supported").with_action(action_name));
return Err(Error::from_text(format!("{}: Only 4 and 8bit color depth are supported", action_name)));
}
}
};
if info.color_type != png::ColorType::Indexed {
return Err(Error::from_str("PNG file must be indexed").with_action(action_name));
return Err(Error::from_text(format!("{}: PNG file must be indexed", action_name)));
}
else {
@@ -54,7 +54,7 @@ impl IndexedImage {
}
Err(err) => {
Err(Error::from_error(err).with_action(action_name))
Err(Error::from_text(format!("{}: {}", action_name, err.to_string())))
}
}
}