Skip to content

Commit

Permalink
handle csl error in graphql #590
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 24, 2020
1 parent 7a13740 commit 2dda0f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 6 additions & 4 deletions app/graphql/lupo_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ class LupoSchema < GraphQL::Schema
GraphQL::ExecutionError.new(exception.record.errors.full_messages.join("\n"))
end

rescue_from CSL::ParseError do |exception|
Raven.capture_exception(exception)
message = exception.message
GraphQL::ExecutionError.new(message)
end

rescue_from StandardError do |exception|
Raven.capture_exception(exception)
message = Rails.env.production? ? "We are sorry, but an error has occured. This problem has been logged and support has been notified. Please try again later. If the error persists please contact support." : exception.message
GraphQL::ExecutionError.new(message)
end

# rescue_from CustomError do |exception, object, arguments, context|
# nil
# end
end
2 changes: 0 additions & 2 deletions app/graphql/types/doi_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ def formatted_citation(style: nil, locale: nil)
url = "https://doi.org/#{object.doi}"
end
bibliography.first.gsub(url, doi_link(url))
rescue CSL::ParseError => e
"Error: #{e.message}"
end

def references(**args)
Expand Down

0 comments on commit 2dda0f7

Please sign in to comment.