Sha256: 741703900f82e0588deee4639d828965f2a6433226a1905478e45ca31a70d7dc

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

module Awestruct
  class ExceptionHelper
    @@failed = false

    def self.log_message message
      $LOG.error message if $LOG.error?
    end

    def self.log_error exception
      mark_failed
      $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}" if $LOG.error?
      self.log_error exception
      self.log_backtrace exception
    end

    def self.mark_failed
      @@failed = true
    end

    def self.build_failed?
      return @@failed
    end

    def self.html_error_report exception, relative_source_path
      mark_failed
      "<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

12 entries across 12 versions & 1 rubygems

Version Path
awestruct-0.5.6.beta8 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta7 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta6 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta5 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta4 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta3 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta2 lib/awestruct/util/exception_helper.rb
awestruct-0.5.6.beta lib/awestruct/util/exception_helper.rb
awestruct-0.5.5 lib/awestruct/util/exception_helper.rb
awestruct-0.5.4.2 lib/awestruct/util/exception_helper.rb
awestruct-0.5.4.1 lib/awestruct/util/exception_helper.rb
awestruct-0.5.4 lib/awestruct/util/exception_helper.rb