Module: ExceptionAlarmInclusion

Defined in:
lib/exception_alarm.rb

Instance Method Summary collapse

Instance Method Details

#alarm(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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