Merge branch 'main' into 6649-etq-usager-instructeur-rendre-la-suppression-plus-visible
This commit is contained in:
commit
49bb12a70e
1 changed files with 11 additions and 0 deletions
|
@ -8,6 +8,8 @@ class API::V2::GraphqlController < API::V2::BaseController
|
||||||
operation_name: params[:operationName])
|
operation_name: params[:operationName])
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
|
rescue GraphQL::ParseError => exception
|
||||||
|
handle_parse_error(exception)
|
||||||
rescue => exception
|
rescue => exception
|
||||||
if Rails.env.production?
|
if Rails.env.production?
|
||||||
handle_error_in_production(exception)
|
handle_error_in_production(exception)
|
||||||
|
@ -88,6 +90,15 @@ class API::V2::GraphqlController < API::V2::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_parse_error(exception)
|
||||||
|
render json: {
|
||||||
|
errors: [
|
||||||
|
{ message: exception.message }
|
||||||
|
],
|
||||||
|
data: nil
|
||||||
|
}, status: 400
|
||||||
|
end
|
||||||
|
|
||||||
def handle_error_in_development(exception)
|
def handle_error_in_development(exception)
|
||||||
logger.error exception.message
|
logger.error exception.message
|
||||||
logger.error exception.backtrace.join("\n")
|
logger.error exception.backtrace.join("\n")
|
||||||
|
|
Loading…
Add table
Reference in a new issue