lib/awestruct/page.rb in awestruct-0.4.8 vs lib/awestruct/page.rb in awestruct-0.5.0.cr

- old
+ new

@@ -41,11 +41,11 @@ context end def inherit_front_matter_from(hash) hash.each do |k,v| - #puts "#{self.output_path} overwrite key: #{k}:#{self[k]} -> #{v}" if ( key?( k ) and !self[k].nil? and !self[k].eql? v) + $LOG.debug "#{self.output_path} overwrite key: #{k}:#{self[k]} -> #{v}" if ( key?( k ) and !self[k].nil? and !self[k].eql? v) if $LOG.debug? unless ( key?( k ) ) self[k.to_sym] = v end end end @@ -128,13 +128,26 @@ Awestruct::Dependencies.push_page( self ) end c = nil begin + $LOG.debug "calling rendered_content on handler for page #{self.output_path}" if $LOG.debug? c = handler.rendered_content( context, with_layouts ) # c = site.engine.pipeline.apply_transformers( context.site, self, c ) - rescue => e - raise $!, "Failed to render #{self.url}", $!.backtrace + rescue StandardError => e + lineno = nil + if e.respond_to?(:lineno) + lineno = e.lineno + elsif e.respond_to?(:line) + lineno = e.line + end + if lineno + if self.handler.respond_to?(:content_line_offset) + lineno += self.handler.content_line_offset + end + end + lineinfo = lineno ? " at line #{lineno}" : '' + raise StandardError, %(Failed to render #{self.relative_source_path}#{lineinfo}\n#{e.class}: #{e.message.rstrip}), e.backtrace.join("\n") end if context.site.config.track_dependencies Awestruct::Dependencies.pop_page