Skip to content

Commit

Permalink
switch to query error variant that propagates error messages to Graph…
Browse files Browse the repository at this point in the history
…QL responses (#39)

When we encounter problems with incoming query requests we've been sending back `QueryError::InvalidQuery` error values. But when the engine receives these it produces GraphQL responses that only say "internal error". This change switches to `QueryError::UnprocessableContent`. With this change the engine copies error messages from the connector to the GraphQL response.
  • Loading branch information
hallettj committed Apr 14, 2024
1 parent 27fc934 commit b86c233
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/mongodb-connector/src/error_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn mongo_agent_error_to_query_error(error: MongoAgentError) -> QueryError {
}
let (status, err) = error.status_and_error_response();
match status {
StatusCode::BAD_REQUEST => QueryError::InvalidRequest(err.message),
StatusCode::BAD_REQUEST => QueryError::UnprocessableContent(err.message),
_ => QueryError::Other(Box::new(error)),
}
}
Expand All @@ -19,7 +19,7 @@ pub fn mongo_agent_error_to_explain_error(error: MongoAgentError) -> ExplainErro
}
let (status, err) = error.status_and_error_response();
match status {
StatusCode::BAD_REQUEST => ExplainError::InvalidRequest(err.message),
StatusCode::BAD_REQUEST => ExplainError::UnprocessableContent(err.message),
_ => ExplainError::Other(Box::new(error)),
}
}

0 comments on commit b86c233

Please sign in to comment.