Skip to content

Error Messages do not give hints, what element caused the error. #571

Description

@mohs8421

I am currently working in the context of SUPL, where the rasn compiler generated these pieces:

    #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
    #[rasn(delegate, identifier = "MCC-MNC-Digit", value("0..=9"))]
    pub struct MCCMNCDigit(pub u8);
    #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
    #[rasn(delegate, size("2..=3"))]
    pub struct MNC(pub SequenceOf<MCCMNCDigit>);

This was used in a larger context, and I had a failure on an attemt to use rasn::uper::encode.
The error I get was looking like this:

EncodeError { kind: InvalidLength { length: 0, expected: Range { start: Some(2), end: Some(3) } }, codec: Uper, backtrace: Backtrace(()) }

For the error itself this information is certainly correct, but in using this it is insufficient. It took me quite some time to get the information, that the MNC declaration was behind this length constraint.

I traced it back to encode_with_tag_and_constraints in which I found the required information. I suggest to enrich the error information at this point to improve it's usability.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions