Module: ABRT
- Defined in:
- lib/abrt/exception.rb,
lib/abrt/handler.rb
Overview
This might be removed if http://bugs.ruby-lang.org/issues/6286 gets accepted.
Defined Under Namespace
Modules: Exception
Class Method Summary collapse
- .abrt_socket ⇒ Object
- .handle_exception(exception) ⇒ Object
- .report(exception, io = abrt_socket) ⇒ Object
- .syslog ⇒ Object
- .write_dump(exception) ⇒ Object
Class Method Details
.abrt_socket ⇒ Object
62 63 64 |
# File 'lib/abrt/handler.rb', line 62 def self.abrt_socket UNIXSocket.new ABRT_SOCKET_PATH end |
.handle_exception(exception) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/abrt/handler.rb', line 7 def self.handle_exception(exception) exception.extend(ABRT::Exception) syslog.notice "detected unhandled Ruby exception in '#{exception.executable}'" # Report only scripts with absolute path. write_dump(exception) if exception.executable[0] == '/' end |
.report(exception, io = abrt_socket) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/abrt/handler.rb', line 22 def self.report(exception, io = abrt_socket) io.write "PUT / HTTP/1.1\r\n\r\n" io.write "PID=#{Process.pid}\0" io.write "EXECUTABLE=#{exception.executable.gsub(/\u0000/, '')}\0" io.write "ANALYZER=Ruby\0" io.write "TYPE=Ruby\0" io.write "BASENAME=rbhook\0" io.write "REASON=#{exception.format.first.gsub(/\u0000/, '')}\0" io.write "BACKTRACE=#{exception.format.join("\n").gsub(/\u0000/, '')}\0" io.close_write yield io.read io.close rescue StandardError => e syslog.err "%s", "can't communicate with ABRT daemon, is it running? #{e.}" end |
.syslog ⇒ Object
18 19 20 |
# File 'lib/abrt/handler.rb', line 18 def self.syslog @syslog ||= Syslog.open 'abrt' end |
.write_dump(exception) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/abrt/handler.rb', line 40 def self.write_dump(exception) report exception do |response| if response.empty? syslog.err "error sending data to ABRT daemon. Empty response received" else parts = response.split code = Integer(parts[1]) rescue false if (parts.size < 2) or (not parts[0] =~ %r{^HTTP/}) or (not code) or (code >= 400) then syslog.err "%s", "error sending data to ABRT daemon: #{response}" end end end end |