Module: Exceptional::Rake

Defined in:
lib/exceptional/integration/rake.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Integrates Exceptional with Rake

Usage:

Simply load it inside of your Rakefile.

require “exceptional” require “exceptional/integration/rake”

task :exceptional do

...
# exception happens here
raise SomeUnexpectedException
...

end

Remember to load your Exceptional configuration if you’re using Exceptional outside Rails

Exceptional::Config.load(“/path/to/config.yml”)



24
25
26
27
28
# File 'lib/exceptional/integration/rake.rb', line 24

def self.included(base)
  base.send(:alias_method,
            :standard_exception_handling,
            :standard_exception_handling_with_exceptional)
end

Instance Method Details

#standard_exception_handling_with_exceptionalObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/exceptional/integration/rake.rb', line 30

def standard_exception_handling_with_exceptional
    begin
      yield
    rescue SystemExit => ex
      # Exit silently with current status
      raise
    rescue OptionParser::InvalidOption => ex
      $stderr.puts ex.message
      exit(false)
    rescue Exception => ex
      # Exit with error message
      Exceptional::Catcher.handle(ex)
      display_error_message(ex)
      Exceptional.clear!
      exit(false)
    end
end