Sha256: f2b6c1ddb712f9c8b2dbc6825d13f71e3183102008a13342605d147f09457a8f

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

module Awestruct
  class ExceptionHelper

    EXITCODES = {:generation_error => 125, :success => 0}

    @@failed = false

    def self.log_message message
      $LOG.error message
    end

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

    def self.log_backtrace exception
      $LOG.error "#{exception.backtrace.join("\n")}"
    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.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

13 entries across 13 versions & 1 rubygems

Version Path
awestruct-0.6.7 lib/awestruct/util/exception_helper.rb
awestruct-0.6.6 lib/awestruct/util/exception_helper.rb
awestruct-0.6.5 lib/awestruct/util/exception_helper.rb
awestruct-0.6.4 lib/awestruct/util/exception_helper.rb
awestruct-0.6.3 lib/awestruct/util/exception_helper.rb
awestruct-0.6.2 lib/awestruct/util/exception_helper.rb
awestruct-0.6.1 lib/awestruct/util/exception_helper.rb
awestruct-0.6.0 lib/awestruct/util/exception_helper.rb
awestruct-0.6.0.RC1 lib/awestruct/util/exception_helper.rb
awestruct-0.6.0.alpha4 lib/awestruct/util/exception_helper.rb
awestruct-0.6.0.alpha3 lib/awestruct/util/exception_helper.rb
awestruct-0.6.0.alpha1 lib/awestruct/util/exception_helper.rb
awestruct-0.5.7 lib/awestruct/util/exception_helper.rb