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