module ExceptionAlarmInclusion

Public Instance Methods

alarm(&block) click to toggle source
# File lib/exception_alarm.rb, line 6
def alarm(&block)
  begin
    block.call
  rescue => e
    mpg123_command = find_executable0 ExceptionAlarm::PLAY_COMMAND
    if mpg123_command
      Thread.new do
        `#{mpg123_command} '#{File.expand_path('../alarm.mp3', __FILE__)}' &> '#{File::NULL}'`
      end
    else
      $stderr.puts ExceptionAlarm.mpg123_not_found
    end
    e.backtrace.select!{|b| !b.include?(__FILE__)}
    raise e
  end
end