Exception: Arachni::Reactor::Connection::Error

Inherits:
Error
  • Object
show all
Defined in:
lib/arachni/reactor/connection/error.rb

Overview

Arachni::Reactor::Connection error namespace.

All Arachni::Reactor::Connection errors inherit from and live under it.

Author:

Direct Known Subclasses

BrokenPipe, Closed, HostNotFound, Permission, Refused, Reset, SSL, Timeout

Defined Under Namespace

Classes: BrokenPipe, Closed, HostNotFound, Permission, Refused, Reset, SSL, Timeout

Class Method Summary collapse

Class Method Details

.raise_with_proper_backtrace(ruby, arachni) ⇒ Object



58
59
60
61
62
# File 'lib/arachni/reactor/connection/error.rb', line 58

def raise_with_proper_backtrace( ruby, arachni )
    e = arachni.new( ruby.to_s )
    e.set_backtrace ruby.backtrace
    raise e
end

.translate(&block) ⇒ Object

Captures Ruby exceptions and converts them to an appropriate subclass of Arachni::Reactor::Connection::Error.

Parameters:

  • block (Block)

    Block to run.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/arachni/reactor/connection/error.rb', line 25

def translate( &block )
    block.call
rescue IOError, Errno::ENOTCONN, Errno::ENOTSOCK => e
    raise_with_proper_backtrace( e, Closed )
rescue SocketError, Errno::ENOENT => e
    raise_with_proper_backtrace( e, HostNotFound )
rescue Errno::EPIPE => e
    raise_with_proper_backtrace( e, BrokenPipe )
rescue Errno::ECONNREFUSED,
    # JRuby throws Errno::EADDRINUSE when trying to connect to a
    # non-existent server.
    Errno::EADDRINUSE => e
    raise_with_proper_backtrace( e, Refused )
rescue Errno::ECONNRESET, Errno::ECONNABORTED => e
    raise_with_proper_backtrace( e, Reset )
rescue Errno::EACCES => e
    raise_with_proper_backtrace( e, Permission )

# Catch and forward these before handling OpenSSL::OpenSSLError because
# all SSL errors inherit from it, including OpenSSL::SSL::SSLErrorWaitReadable
# and OpenSSL::SSL::SSLErrorWaitWritable which also inherit from
# IO::WaitReadable and IO::WaitWritable and need special treatment.
rescue IO::WaitReadable, IO::WaitWritable, Errno::EINPROGRESS
    raise

# We're mainly interested in translating SSL handshake errors but there
# aren't any specific exceptions for these.
#
# Why make things easy and clean, right?
rescue OpenSSL::SSL::SSLError, OpenSSL::OpenSSLError => e
    raise_with_proper_backtrace( e, SSL )
end