mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
27 lines
812 B
Ruby
27 lines
812 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Docs
|
|
class ImageSubscriber < Subscriber
|
|
self.namespace = 'image'
|
|
|
|
def broken(event)
|
|
log "Skipped broken image (#{event.payload[:code]}): #{event.payload[:url]}"
|
|
end
|
|
|
|
def invalid(event)
|
|
log "Skipped invalid image (#{event.payload[:content_type]}): #{event.payload[:url]}"
|
|
end
|
|
|
|
def too_big(event)
|
|
log "Skipped large image (#{(event.payload[:size] / 1_000.0).round} KB): #{event.payload[:url]}"
|
|
end
|
|
|
|
def error(event)
|
|
exception = event.payload[:exception]
|
|
log "ERROR: #{event.payload[:url]}"
|
|
puts " #{exception.class}: #{exception.message.gsub("\n", "\n ")}"
|
|
puts exception.backtrace.select { |line| line.start_with?(Docs.root_path) }.join("\n ").prepend("\n ")
|
|
puts "\n"
|
|
end
|
|
end
|
|
end
|