Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide proper errors #87

Open
apbr opened this issue Oct 31, 2023 · 1 comment
Open

Provide proper errors #87

apbr opened this issue Oct 31, 2023 · 1 comment

Comments

@apbr
Copy link

apbr commented Oct 31, 2023

Currently there is only one error when something goes wrong (The empty struct BitsError). So it is quite difficult to find out what exactly is causing the error.
Please at least add some indication which struct/enum is causing the error.
For example in the following code the error should point out that Bar has no variant that matches 0b0001:

    fn error_test(){
        #[bitsize(4)]
        #[derive(TryFromBits)]
        enum Foo {
            One = 0b0001,
            Two = 0b0010,
        };

        #[bitsize(4)]
        #[derive(TryFromBits)]
        enum Bar {
            Three = 0b0011,
            Four = 0b0100,
        };

        #[bitsize(8)]
        #[derive(TryFromBits)]
        struct Byte {
            foo: Foo,
            bar: Bar,
        }
        let b = Byte::try_from(0b0001_0001).unwrap();
    }
@hecatia-elegua
Copy link
Owner

hecatia-elegua commented Nov 21, 2023

See #40 for some previous discussion.
I would love to have this too.

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

No branches or pull requests

2 participants