Skip to content

Commit

Permalink
rename CustomError to ParseError
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Jul 27, 2023
1 parent af46592 commit 6b89eca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions command/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use nom::{

#[derive(Debug)]
#[allow(dead_code)]
pub struct CustomError {
pub struct ParseError {
kind: ErrorKind,
serde_json_error: Option<serde_json::Error>,
}

impl FromExternalError<&[u8], serde_json::Error> for CustomError {
impl FromExternalError<&[u8], serde_json::Error> for ParseError {
fn from_external_error(
_input: &[u8],
kind: ErrorKind,
Expand All @@ -26,7 +26,7 @@ impl FromExternalError<&[u8], serde_json::Error> for CustomError {
}
}

impl nom::error::ParseError<&[u8]> for CustomError {
impl nom::error::ParseError<&[u8]> for ParseError {
fn from_error_kind(_input: &[u8], kind: ErrorKind) -> Self {
// println!("input: {:?}, error kind: {:?}", input, kind);

Expand All @@ -42,7 +42,7 @@ impl nom::error::ParseError<&[u8]> for CustomError {
}

/// Parse a single Request or WorkerRequest
pub fn parse_one_request<'a, T>(input: &'a [u8]) -> IResult<&[u8], T, CustomError>
pub fn parse_one_request<'a, T>(input: &'a [u8]) -> IResult<&[u8], T, ParseError>
where
T: serde::de::Deserialize<'a>,
{
Expand All @@ -51,7 +51,7 @@ where
let command = match serde_json::from_slice::<T>(json_data) {
Ok(user) => user,
Err(serde_error) => {
return Err(nom::Err::Failure(CustomError::from_external_error(
return Err(nom::Err::Failure(ParseError::from_external_error(
input,
ErrorKind::MapRes,
serde_error,
Expand All @@ -65,7 +65,7 @@ where
}

/// Parse a Requests or WorkerRequests using nom
pub fn parse_several_requests<'a, T>(input: &'a [u8]) -> IResult<&[u8], Vec<T>, CustomError>
pub fn parse_several_requests<'a, T>(input: &'a [u8]) -> IResult<&[u8], Vec<T>, ParseError>
where
T: serde::de::Deserialize<'a>,
{
Expand Down

0 comments on commit 6b89eca

Please sign in to comment.