Class: MailRoom::CrashHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mail_room/crash_handler.rb

Constant Summary collapse

SUPPORTED_FORMATS =
%w[json none]

Instance Method Summary collapse

Constructor Details

#initialize(stream = STDOUT) ⇒ CrashHandler

Returns a new instance of CrashHandler.


7
8
9
# File 'lib/mail_room/crash_handler.rb', line 7

def initialize(stream=STDOUT)
  @stream = stream
end

Instance Method Details

#handle(error, format) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/mail_room/crash_handler.rb', line 11

def handle(error, format)
  if format == 'json'
    @stream.puts json(error)
    return
  end

  raise error
end