stomp_parser/
error.rs

1//! Defines error types used and returned by this package.
2use std::convert::Into;
3
4use nom::error::{ContextError, FromExternalError, ParseError, VerboseError};
5
6#[derive(Debug)]
7pub struct StompParseError {
8    message: String,
9}
10
11impl StompParseError {
12    pub fn new<S: Into<String>>(message: S) -> StompParseError {
13        StompParseError {
14            message: message.into(),
15        }
16    }
17
18    pub fn message(&self) -> &str {
19        &self.message
20    }
21}
22
23impl From<std::io::Error> for StompParseError {
24    fn from(io_error: std::io::Error) -> Self {
25        StompParseError::new(format!("IO-Error writing item: {:?}", io_error))
26    }
27}
28
29pub trait FullError<I, E>: ParseError<I> + FromExternalError<I, E> + ContextError<I> {}
30
31impl<I, E> FullError<I, E> for VerboseError<I> {}