lib/webdrone/error.rb in webdrone-0.8.4 vs lib/webdrone/error.rb in webdrone-0.9.0
- old
+ new
@@ -8,21 +8,18 @@
@caller_locations = caller_locations
@buffer = []
begin
# find location of user error
- @caller_locations[1..-1].each do |location|
- if not location.path.include? 'lib/webdrone/'
+ @caller_locations[0..-1].each do |location|
+ if Gem.path.none? { |path| location.path.include? path }
@location = location
break
end
end
- report_script
- report_screenshot
- report_exception
- report_time
+ report if a0.conf.error == :raise_report
rescue
end
end
def write_line(line)
@@ -45,10 +42,17 @@
file.write(@buffer.join)
end
@buffer = []
end
+ def report
+ report_script
+ report_screenshot
+ report_exception
+ report_time
+ end
+
def report_script
begin
ini, fin = [@location.lineno - 10 - 1, @location.lineno + 10 - 1]
ini = 0 if ini < 0
@@ -102,12 +106,10 @@
dump_error_report
end
end
def self.report_error(a0, exception, caller_locations)
- if exception.class == WebdroneError
- raise exception
- end
-
- raise WebdroneError.new(exception.message, exception, a0, caller_locations)
+ exception = WebdroneError.new(exception.message, exception, a0, caller_locations) if exception.class != WebdroneError
+
+ raise exception if a0.conf.error == :raise or a0.conf.error == :raise_report
end
end