./lib/lux/error/error.rb in lux-fw-0.1.17 vs ./lib/lux/error/error.rb in lux-fw-0.1.35

- old
+ new

@@ -14,18 +14,17 @@ # 503: for too many requests at the same time RateLimitError ||= Class.new(StandardError) module Lux::Error - OUT_OF_PROCESS_ERROR_PATH = Lux.root.join('tmp/request-error.txt') - extend self def try(name) begin yield rescue + Lux.page.status 500 log($!) inline('%s (%s)' % [name, $!.class]) end end @@ -39,13 +38,24 @@ Lux.page.body! render(data) end def inline(name=nil, o=nil) o ||= $! - trace = o.backtrace.select{ |el| el.index(Lux.root.to_s) }.map{ |el| el.split(Lux.root.to_s, 2)[1] }.map{ |el| "- #{el}" }.join("\n") - msg = $!.to_s.gsub('","',%[",\n "]).gsub('<','&lt;') - %[<pre style="color:red; background:#eee; padding:10px; font-family:'Lucida Console'; line-height:14pt; font-size:10pt;"><b style="font-size:110%;">#{name || 'Undefined name'}</b>\n\n<b>#{msg}</b>\n\n#{trace}</pre>] + + dmp = [[], []] + + o.backtrace.each do |line| + line = line.sub(Lux.root.to_s, '.') + dmp[line.include?('/app/') ? 0 : 1].push line + end + + dmp[0] = dmp[0].map { |_| _ = _.split(':', 3); '<b>%s</b> - %s - %s' % _ } + + name ||= 'Undefined name' + msg = $!.to_s.gsub('","',%[",\n "]).gsub('<','&lt;') + + %[<pre style="color:red; background:#eee; padding:10px; font-family:'Lucida Console'; line-height:15pt; font-size:11pt;"><b style="font-size:110%;">#{name}</b>\n\n<b>#{msg}</b>\n\n#{dmp[0].join("\n")}\n\n#{dmp[1].join("\n")}</pre>] end def log(exception) return if Lux.env == 'test' return unless Lux.page @@ -61,15 +71,6 @@ folder += "/#{exception.class.to_s.tableize.gsub('/','-')}" Dir.mkdir(folder) unless Dir.exists?(folder) File.write("#{folder}/#{key}.txt", data) end - - - # if some other process as asset complation raises error - # use this method to show errors - def log_out_of_process_error(data) - return unless Lux.config(:show_server_errors) - File.write OUT_OF_PROCESS_ERROR_PATH, data - end - end