graphql_tools/parser/query/
error.rs1use std::fmt::Display;
2
3use combine::easy::Errors;
4use thiserror::Error;
5
6use crate::parser::position::Pos;
7use crate::parser::tokenizer::Token;
8
9pub type InternalError<'a> = Errors<Token<'a>, Token<'a>, Pos>;
10
11#[derive(Error, Debug)]
16pub struct ParseError(pub InternalError<'static>);
17
18impl<'a> From<InternalError<'a>> for ParseError {
19 fn from(e: InternalError<'a>) -> ParseError {
20 let e = unsafe { std::mem::transmute::<InternalError<'a>, InternalError<'static>>(e) };
21 ParseError(e)
22 }
23}
24
25impl Display for ParseError {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 write!(f, "{}", self.0)
28 }
29}