diff --git a/app/controllers/clients_controller.rb b/app/controllers/clients_controller.rb index 919c6fc85..72dc8d148 100644 --- a/app/controllers/clients_controller.rb +++ b/app/controllers/clients_controller.rb @@ -61,6 +61,8 @@ def index options[:is_collection] = true render json: ClientSerializer.new(@clients, options).serialized_json, status: :ok + rescue Elasticsearch::Transport::Transport::Errors::GatewayTimeout => exception + head :gateway_timeout rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception Raven.capture_exception(exception) diff --git a/app/controllers/dois_controller.rb b/app/controllers/dois_controller.rb index fd97d3e8f..8e576d968 100644 --- a/app/controllers/dois_controller.rb +++ b/app/controllers/dois_controller.rb @@ -156,7 +156,11 @@ def index end format.any(:bibtex, :citeproc, :codemeta, :crosscite, :datacite, :datacite_json, :jats, :ris, :csv, :schema_org) { render request.format.to_sym => response.records.to_a } end + rescue Elasticsearch::Transport::Transport::Errors::GatewayTimeout => exception + head :gateway_timeout rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception + Raven.capture_exception(exception) + message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason") render json: { "errors" => { "title" => message }}.to_json, status: :bad_request diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 59c756aec..ccf07d814 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -60,9 +60,11 @@ def index options[:links] = nil render json: MemberSerializer.new(@members, options).serialized_json, status: :ok + rescue Elasticsearch::Transport::Transport::Errors::GatewayTimeout => exception + head :gateway_timeout rescue Elasticsearch::Transport::Transport::Errors::BadRequest => exception - # Bugsnag.notify(exception) - + Raven.capture_exception(exception) + message = JSON.parse(exception.message[6..-1]).to_h.dig("error", "root_cause", 0, "reason") render json: { "errors" => { "title" => message }}.to_json, status: :bad_request diff --git a/config/initializers/_version.rb b/config/initializers/_version.rb index 8ee283182..9794a42ab 100644 --- a/config/initializers/_version.rb +++ b/config/initializers/_version.rb @@ -1,6 +1,6 @@ module Lupo class Application - g = Git.open(Rails.root, :log => Logger.new(STDOUT)) + g = Git.open(Rails.root) begin VERSION = g.tags.map { |t| Gem::Version.new(t.name) }.sort.last.to_s rescue ArgumentError