Graph::Schema.execute(query, variables: variables, context: context) rescue => e handle_error e end private def authenticate # ...
ErrorReporting.assign_user(@user) end
def handle_error(error) if Rails.env.development? logger.error error.message logger.error error.backtrace.join("\n") render json: { error: { message: error.message, backtrace: error.backtrace } }, status: 500 elsif Rails.env.test? p error.message p error.backtrace render json: { error: { message: error.message, backtrace: error.backtrace } }, status: 500 else ErrorReporting.capture(e, query: query) render json: { error: { message: 'SERVER_ERROR' }, data: {} }, status: 500 end end end