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

Return with custom ErrorKind at nom 5.0 #394

Open
NamsooCho opened this issue Jun 27, 2019 · 0 comments
Open

Return with custom ErrorKind at nom 5.0 #394

NamsooCho opened this issue Jun 27, 2019 · 0 comments

Comments

@NamsooCho
Copy link
Member

Nom 5 don't have custom ErrorKind now.
But I want to return with custom error kind in this situation.

let request = if let Some(request) = request {
request
} else {
return Err(Err::Error((input, ErrorKind::NoneOf)));
};
let capabilities = if let Some(capabilities) = capabilities {
capabilities
} else {
return Err(Err::Error((input, ErrorKind::NoneOf)));
};

It is needed when the Msi packet don't have a Request subpacket or Capability subpacket,
Now we return with ErrorKind::NoneOf, but it would be better to return with exact explanation why the error occurred.

The error kinds I want to use are

const NOM_CUSTOM_ERR_REQUEST_SUBPACKET_OMITTED: u32 = 1;
const NOM_CUSTOM_ERR_CAPABILITIES_SUBPACKET_OMITTED: u32 = 2;

Any idea?

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

1 participant