Sha256: 950ef3966b70b936071dfc8d76652f647f17788a0d9ac93611a6ffddc61396ae

Contents?: true

Size: 878 Bytes

Versions: 2

Compression:

Stored size: 878 Bytes

Contents

module Awestruct
  class ExceptionHelper
    def self.log_message message
      $LOG.error message if $LOG.error
    end

    def self.log_error exception
      $LOG.error "An error occurred: #{exception.message}" if $LOG.error
    end

    def self.log_backtrace exception
      $LOG.error "#{exception.backtrace.join("\n")}" if $LOG.error
    end
    
    def self.log_building_error exception, relative_source_path
      $LOG.error "While processing file #{relative_source_path}"
      self.log_error exception
      self.log_backtrace exception
    end

    def self.html_error_report exception, relative_source_path
"<h1>#{exception.message}</h1>
<h2>Rendering file #{relative_source_path} resulted in a failure.</h2>
<p>Line: #{(exception.respond_to? :line) ? exception.line : 'unknown'}</p>
<p>Backtrace:</p>
<pre>#{exception.backtrace.join "\n"}</pre>"
   end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
awestruct-0.5.4.rc3 lib/awestruct/util/exception_helper.rb
awestruct-0.5.4.rc2 lib/awestruct/util/exception_helper.rb