Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

Commit

Permalink
Merge 928bf2c into 5e3721c
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Dec 3, 2017
2 parents 5e3721c + 928bf2c commit 056afbc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/push.rb
Expand Up @@ -139,7 +139,16 @@ def configure_index(index)
end

# Display the error in a human-friendly way if possible
def display_error(error)
def display_error(error, batch = nil)
if batch.present? && error.message =~ /"message":\s*"Record at the position/
idx = /Record at the position (\d+) is/.match(error.message)[1].to_i
record = batch[idx.to_i]
Jekyll.logger.error 'Algolia Error: Record too big'
Jekyll.logger.warn "Record path: #{record[:url]} § #{record[:unique_hierarchy]}"
Jekyll.logger.warn "Contents: #{record[:text][0...50]}..."
return
end

error_handler = AlgoliaSearchErrorHandler.new
readable_error = error_handler.readable_algolia_error(error.message)

Expand Down Expand Up @@ -172,7 +181,7 @@ def batch_add_items(items, index)
begin
index.add_objects!(batch) unless @is_dry_run
rescue StandardError => error
display_error(error)
display_error(error, batch)
exit 1
end
end
Expand Down

0 comments on commit 056afbc

Please sign in to comment.