debug nom errors
Hi,
I am curious how I can debug nom errors. In nom, most helpful functions (like convert_error) operate under &str while the libsip library uses &[u8]. At some point in my code I have something like:
async fn process_request(request: common::bytes::BytesMut) -> Result<Vec<u8>, String> {
let (_, request) = libsip::parse_message::<VerboseError<&[u8]>>(&request.to_vec())
.map_err(|e| e.to_string())?;
let response = processor::get_response(request).await?;
Ok(format!("{}", response).into_bytes())
}
the e.to_string() does not give very helpful data, even if I do format!("{:?}", e), it's just prints plain binary (array of numbers). Nom provides some pretty good support for human-friendly errors and I would like to use it somehow. Ideas how to convert the libsip VerboseError<&[u8]> to VerboseError<&str> ?
Sorry, I am a bit new to Rust.
In order to have VerboseError<&str> we should have functions that accept &str instead of &[u8]. @bytebuddha Is there a reason they accept input as &[u8]? :-)
The only reason was to simplify reading and writing witch worked with &[u8] but I'm not opposed to change it to &str.
@bytebuddha Are you going to work on it?
@KalitaAlexey I have started messing around with it, I tried first to wrap nom::error::covert_error to work with the VerboseError<&[u8]> but that causes error messages to be invalid. I won't have anytime to work on this for a couple weeks so feel free to and if not I'll pick it up as soon as I get some free time