Skip to content

Use thiserror for humility-arch-arm#676

Open
mkeeter wants to merge 1 commit into
masterfrom
mkeeter/humility-arch-arm-errors
Open

Use thiserror for humility-arch-arm#676
mkeeter wants to merge 1 commit into
masterfrom
mkeeter/humility-arch-arm-errors

Conversation

@mkeeter
Copy link
Copy Markdown
Contributor

@mkeeter mkeeter commented May 21, 2026

This is a tiny PR which gives humility-arch-arm fine-grained error types.

@mkeeter mkeeter requested review from jamesmunns and labbott May 21, 2026 18:44
@mkeeter mkeeter force-pushed the mkeeter/humility-arch-arm-errors branch from 94e5ce8 to ab11e86 Compare May 21, 2026 20:02
@mkeeter mkeeter force-pushed the mkeeter/humility-arch-arm-errors branch from ab11e86 to 8e3f290 Compare May 21, 2026 20:50
Copy link
Copy Markdown

@jamesmunns jamesmunns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the change looks reasonable, we might want to get in the habit of being a bit more complete in documentation, or at least improve-as-we-go.

}

#[derive(Debug, thiserror::Error)]
pub enum InstructionError {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make this #[non_exhaustive] to avoid semver breakage of humility-as-a-lib?

This makes things a little tedious in some places, but we might want to start caring about the impact of semver breaking changes if we expect to start having external consumers.

#[derive(Debug, thiserror::Error)]
pub enum InstructionError {
#[error("multiple source registers")]
MultipleSourceRegisters,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth including doc comments on the enum, and on each variant, at least answering "what does this error mean, and what should a user do about it if they get it". If I got these errors, I'd probably have to go ping you in chat to figure out what I was doing wrong.

If we expect users to start handling these errors (instead of just bailing), we should probably give them some useful feedback!

rval
}

#[derive(Debug, thiserror::Error)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we might also want to hit some common derives here as well, PartialEq, Clone, and Hash are usually big ones.

Clone is just generally useful, PartialEq allows for easier asserting (incl in tests), Hash is also one of those "eventually someone wants to stick it in a map" kind of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants