Skip to content

Return with custom ErrorKind at nom 5.0 #394

Open
@NamsooCho

Description

@NamsooCho

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?

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