Merge pull request #6657 from betagouv/sentry-ignore-parse-errors
GraphQL : affiche la cause des erreurs de syntaxe des requêtes
This commit is contained in:
commit
e934d6ea30
1 changed files with 11 additions and 0 deletions
|
@ -8,6 +8,8 @@ class API::V2::GraphqlController < API::V2::BaseController
|
|||
operation_name: params[:operationName])
|
||||
|
||||
render json: result
|
||||
rescue GraphQL::ParseError => exception
|
||||
handle_parse_error(exception)
|
||||
rescue => exception
|
||||
if Rails.env.production?
|
||||
handle_error_in_production(exception)
|
||||
|
@ -88,6 +90,15 @@ class API::V2::GraphqlController < API::V2::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def handle_parse_error(exception)
|
||||
render json: {
|
||||
errors: [
|
||||
{ message: exception.message }
|
||||
],
|
||||
data: nil
|
||||
}, status: 400
|
||||
end
|
||||
|
||||
def handle_error_in_development(exception)
|
||||
logger.error exception.message
|
||||
logger.error exception.backtrace.join("\n")
|
||||
|
|
Loading…
Reference in a new issue