Add and apply Style/RedundantBegin rubocop rule
We're about to add code which might fall into the `RedundantBegin` category, so we're adding the rule in order to prevent that.
This commit is contained in:
@@ -9,25 +9,23 @@ class GraphqlController < ApplicationController
|
||||
class QueryStringError < StandardError; end
|
||||
|
||||
def execute
|
||||
begin
|
||||
raise GraphqlController::QueryStringError if query_string.nil?
|
||||
raise GraphqlController::QueryStringError if query_string.nil?
|
||||
|
||||
result = ConsulSchema.execute(
|
||||
query_string,
|
||||
variables: prepare_variables,
|
||||
context: {},
|
||||
operation_name: params[:operationName]
|
||||
)
|
||||
render json: result
|
||||
rescue GraphqlController::QueryStringError
|
||||
render json: { message: "Query string not present" }, status: :bad_request
|
||||
rescue JSON::ParserError
|
||||
render json: { message: "Error parsing JSON" }, status: :bad_request
|
||||
rescue GraphQL::ParseError
|
||||
render json: { message: "Query string is not valid JSON" }, status: :bad_request
|
||||
rescue ArgumentError => e
|
||||
render json: { message: e.message }, status: :bad_request
|
||||
end
|
||||
result = ConsulSchema.execute(
|
||||
query_string,
|
||||
variables: prepare_variables,
|
||||
context: {},
|
||||
operation_name: params[:operationName]
|
||||
)
|
||||
render json: result
|
||||
rescue GraphqlController::QueryStringError
|
||||
render json: { message: "Query string not present" }, status: :bad_request
|
||||
rescue JSON::ParserError
|
||||
render json: { message: "Error parsing JSON" }, status: :bad_request
|
||||
rescue GraphQL::ParseError
|
||||
render json: { message: "Query string is not valid JSON" }, status: :bad_request
|
||||
rescue ArgumentError => e
|
||||
render json: { message: e.message }, status: :bad_request
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user