Skip to content

Instantly share code, notes, and snippets.

@thomsbg
Created May 31, 2018 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomsbg/2ae45d42029d894879ea8e37abfe3a9c to your computer and use it in GitHub Desktop.
Save thomsbg/2ae45d42029d894879ea8e37abfe3a9c to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb
index 2e300fc0..02592ea2 100644
--- a/app/controllers/graphql_controller.rb
+++ b/app/controllers/graphql_controller.rb
@@ -9,6 +9,15 @@ def execute
}
result = HermanoGraphQL.schema.execute(query, variables: variables, context: context, operation_name: operation_name)
render json: result
+ rescue StandardError => e
+ e = e.cause while e.cause
+ render status: 200, json: {
+ errors: [{
+ name: e.class.name,
+ message: e.message,
+ time_thrown: Time.now.utc.iso8601
+ }]
+ }
end
def heartbeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment