Unified · Split
| @@ -25,6 +25,9 @@ module Docs · 24 unmodified lines | ||
| 25 | 25 | mattr_accessor :store_path |
| 26 | 26 | self.store_path = File.expand_path '../public/docs', @@root_path |
| 27 | 27 | |
| 28 | + mattr_accessor :rescue_errors | |
| 29 | + self.rescue_errors = false | |
| 30 | + | |
| 28 | 31 | class DocNotFound < NameError; end |
| 29 | 32 | |
| 30 | 33 | def self.all |
| @@ -163,8 +163,12 @@ module Docs · 162 unmodified lines | ||
| 163 | 163 | instrument 'ignore_response.scraper', response: response |
| 164 | 164 | end |
| 165 | 165 | rescue => e |
| 166 | − puts "URL: #{response.url}" | |
| 167 | − raise e | |
| 166 | + if Docs.rescue_errors | |
| 167 | + instrument 'error.doc', exception: e, url: response.url | |
| 168 | + nil | |
| 169 | + else | |
| 170 | + raise e | |
| 171 | + end | |
| 168 | 172 | end |
| 169 | 173 | |
| 170 | 174 | def process_response(response) |
| @@ -20,6 +20,15 @@ module Docs · 19 unmodified lines | ||
| 20 | 20 | log event.payload[:msg] |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | + def error(event) | |
| 24 | + exception = event.payload[:exception] | |
| 25 | + log "ERROR:" | |
| 26 | + puts " #{event.payload[:url]}" | |
| 27 | + puts " #{exception.class}: #{exception.message.gsub("\n", "\n ")}" | |
| 28 | + puts exception.backtrace.select { |line| line.start_with?(Docs.root_path) }.join("\n ").prepend("\n ") | |
| 29 | + puts "\n" | |
| 30 | + end | |
| 31 | + | |
| 23 | 32 | private |
| 24 | 33 | |
| 25 | 34 | def parse_payload(event) |
| @@ -58,6 +58,7 @@ class DocsCLI < Thor · 57 unmodified lines | ||
| 58 | 58 | option :force, type: :boolean |
| 59 | 59 | option :package, type: :boolean |
| 60 | 60 | def generate(name) |
| 61 | + Docs.rescue_errors = true | |
| 61 | 62 | Docs.install_report :store if options[:verbose] |
| 62 | 63 | Docs.install_report :scraper if options[:debug] |
| 63 | 64 | Docs.install_report :progress_bar, :doc if $stdout.tty? |
| @@ -93,6 +94,8 @@ class DocsCLI < Thor · 29 unmodified lines | ||
| 93 | 94 | generate_manifest if result |
| 94 | 95 | rescue Docs::DocNotFound => error |
| 95 | 96 | handle_doc_not_found_error(error) |
| 97 | + ensure | |
| 98 | + Docs.rescue_errors = false | |
| 96 | 99 | end |
| 97 | 100 | |
| 98 | 101 | desc 'manifest', 'Create the manifest' |