Skip to content

Commit 38dbe4a

Browse files
committed
graph: Wrap ParseError in an Arc for cloning
1 parent 9e5ad24 commit 38dbe4a

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

graph/src/data/query/error.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,13 @@ impl From<StoreError> for QueryExecutionError {
260260
}
261261

262262
/// Error caused while processing a [Query](struct.Query.html) request.
263-
#[derive(Debug)]
263+
#[derive(Clone, Debug)]
264264
pub enum QueryError {
265265
EncodingError(FromUtf8Error),
266-
ParseError(failure::Error),
266+
ParseError(Arc<anyhow::Error>),
267267
ExecutionError(QueryExecutionError),
268268
}
269269

270-
impl Clone for QueryError {
271-
fn clone(&self) -> Self {
272-
match self {
273-
QueryError::EncodingError(e) => QueryError::EncodingError(e.clone()),
274-
QueryError::ParseError(e) => QueryError::ParseError(failure::err_msg(e.to_string())),
275-
QueryError::ExecutionError(e) => QueryError::ExecutionError(e.clone()),
276-
}
277-
}
278-
}
279-
280270
impl From<FromUtf8Error> for QueryError {
281271
fn from(e: FromUtf8Error) -> Self {
282272
QueryError::EncodingError(e)

server/http/src/request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ impl Future for GraphQLRequest {
4848
})?;
4949

5050
// Parse the "query" field of the JSON body
51-
let document = graphql_parser::parse_query(query_string)
52-
.map_err(|e| GraphQLServerError::from(QueryError::ParseError(e.into())))?;
51+
let document = graphql_parser::parse_query(query_string).map_err(|e| {
52+
GraphQLServerError::from(QueryError::ParseError(Arc::new(e.compat().into())))
53+
})?;
5354

5455
// Parse the "variables" field of the JSON body, if present
5556
let variables = match obj.get("variables") {

server/index-node/src/request.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ impl Future for IndexNodeRequest {
4949
})?;
5050

5151
// Parse the "query" field of the JSON body
52-
let document = graphql_parser::parse_query(query_string)
53-
.map_err(|e| GraphQLServerError::from(QueryError::ParseError(e.into())))?;
52+
let document = graphql_parser::parse_query(query_string).map_err(|e| {
53+
GraphQLServerError::from(QueryError::ParseError(Arc::new(e.compat().into())))
54+
})?;
5455

5556
// Parse the "variables" field of the JSON body, if present
5657
let variables = match obj.get("variables") {

0 commit comments

Comments
 (0)