I’ve built a small web service using webrick. The service runs on a
separate
thread. When it gets an exception it, apparently, dies…it being the
thread.
Is there a way to catch the exception without the thread exiting? The
code
is opening a file so I wrapped it in a begin/rescue block, but it
doesn’t
seem to help.
begin
File.open(buffer[:file_name], 'a') do |f|
f.print(buffer[:text])
end
rescue Exception
@logger.error("could not write message\n #{$!}\n file
#{buffer[:file_name]}<\n message >#{buffer[:text]}<")
end
If the file is invalid I think the thread dies – but I don’t see a
message
anywhere.
-Kelly