You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Without using nutype, I use the thiserror crate to create Error types and give them relevant error messages:
#[derive(Error,Debug,PartialEq)]pubenumPackageVersionError{#[error("Package version length must be between {} and {} characters",PackageVersion::MIN_LENGTH,PackageVersion::MAX_LENGTH)]InvalidLength,#[error("Package version may not contain whitespace")]ContainsWhitespace,#[error("Package version may not contain any control characters")]ContainsControlChars,#[error("Package version may not contain any of the following characters: {:?}",PackageVersion::DISALLOWED_CHARACTERS)]DisallowedCharacters,}
Currently, trying to achieve a similar thing with nutype will just return error messages like "too short". This isn't helpful as I show the error to the user.
Ideally, I'd like for nutype's error to instead say something like Value is too short. The value length must be between 4 and 128 characters, or the same message but have a value name, such as Package version in my case.
The text was updated successfully, but these errors were encountered:
Without using nutype, I use the
thiserror
crate to create Error types and give them relevant error messages:Currently, trying to achieve a similar thing with nutype will just return error messages like "too short". This isn't helpful as I show the error to the user.
Ideally, I'd like for nutype's error to instead say something like
Value is too short. The value length must be between 4 and 128 characters
, or the same message but have a value name, such asPackage version
in my case.The text was updated successfully, but these errors were encountered: