Skip to content

Commit 420e58f

Browse files
committed
Expose style, hide and shorten parse error names
1 parent c63eb0d commit 420e58f

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ mod helpers;
106106
pub mod query;
107107
pub mod schema;
108108

109-
pub use query::{parse_query, QueryParseError};
110-
pub use schema::{parse_schema, SchemaParseError};
109+
pub use query::parse_query;
110+
pub use schema::parse_schema;
111111
pub use position::Pos;
112+
pub use format::Style;

src/query/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ pub type InternalError<'a> = Errors<Token<'a>, Token<'a>, Pos>;
1212
/// way to improve both error message and API.
1313
#[derive(Fail, Debug)]
1414
#[fail(display="query parse error: {}", _0)]
15-
pub struct QueryParseError(String);
15+
pub struct ParseError(String);
1616

17-
impl<'a> From<InternalError<'a>> for QueryParseError {
18-
fn from(e: InternalError<'a>) -> QueryParseError {
19-
QueryParseError(format!("{}", e))
17+
impl<'a> From<InternalError<'a>> for ParseError {
18+
fn from(e: InternalError<'a>) -> ParseError {
19+
ParseError(format!("{}", e))
2020
}
2121
}

src/query/grammar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use common::{Directive};
55
use common::{directives, arguments, default_value, parse_type};
66
use tokenizer::{TokenStream};
77
use helpers::{punct, ident, name};
8-
use query::error::{QueryParseError};
8+
use query::error::{ParseError};
99
use query::ast::*;
1010

1111
pub fn field<'a>(input: &mut TokenStream<'a>)
@@ -182,7 +182,7 @@ pub fn definition<'a>(input: &mut TokenStream<'a>)
182182
}
183183

184184
/// Parses a piece of query language and returns an AST
185-
pub fn parse_query(s: &str) -> Result<Document, QueryParseError> {
185+
pub fn parse_query(s: &str) -> Result<Document, ParseError> {
186186
let mut tokens = TokenStream::new(s);
187187
let (doc, _) = many1(parser(definition))
188188
.map(|d| Document { definitions: d })

src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mod grammar;
77

88

99
pub use self::grammar::parse_query;
10-
pub use self::error::QueryParseError;
10+
pub use self::error::ParseError;
1111
pub use self::ast::*;

src/schema/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ pub type InternalError<'a> = Errors<Token<'a>, Token<'a>, Pos>;
1212
/// way to improve both error message and API.
1313
#[derive(Fail, Debug)]
1414
#[fail(display="schema parse error: {}", _0)]
15-
pub struct SchemaParseError(String);
15+
pub struct ParseError(String);
1616

17-
impl<'a> From<InternalError<'a>> for SchemaParseError {
18-
fn from(e: InternalError<'a>) -> SchemaParseError {
19-
SchemaParseError(format!("{}", e))
17+
impl<'a> From<InternalError<'a>> for ParseError {
18+
fn from(e: InternalError<'a>) -> ParseError {
19+
ParseError(format!("{}", e))
2020
}
2121
}

src/schema/grammar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use failure::Fail;
88
use tokenizer::{Kind as T, Token, TokenStream};
99
use helpers::{punct, ident, kind, name};
1010
use common::{directives, string, default_value, parse_type};
11-
use schema::error::{SchemaParseError};
11+
use schema::error::{ParseError};
1212
use schema::ast::*;
1313

1414

@@ -526,7 +526,7 @@ pub fn definition<'a>(input: &mut TokenStream<'a>)
526526
}
527527

528528
/// Parses a piece of schema language and returns an AST
529-
pub fn parse_schema(s: &str) -> Result<Document, SchemaParseError> {
529+
pub fn parse_schema(s: &str) -> Result<Document, ParseError> {
530530
let mut tokens = TokenStream::new(s);
531531
let (doc, _) = many1(parser(definition))
532532
.map(|d| Document { definitions: d })

src/schema/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ mod error;
66
mod format;
77

88
pub use self::ast::*;
9-
pub use self::error::SchemaParseError;
9+
pub use self::error::ParseError;
1010
pub use self::grammar::parse_schema;

0 commit comments

Comments
 (0)