Module: UnixSocks::ServerError

Defined in:
lib/unix_socks/server_error.rb

Overview

Marker module for UnixSocks server-related errors.

This module is mixed into exceptions raised by UnixSocks server implementations to provide a common rescue clause for server-related errors.

Examples:

Handling server errors

begin
  server.receive { |message| process_message(message) }
rescue UnixSocks::ServerError
  # Handle all UnixSocks server errors consistently
end

Class Method Summary collapse

Class Method Details

.build(exception, message) ⇒ Exception

Builds a server error exception with the given exception class and message.

This method creates a new exception instance of the specified exception class with the provided message, marks it with the ServerError module, and returns the marked exception.

Parameters:

  • exception (Class)

    The exception class to be instantiated

  • message (String)

    The error message for the exception

Returns:

  • (Exception)

    A new exception instance marked with ServerError module



24
25
26
# File 'lib/unix_socks/server_error.rb', line 24

def self.build(exception, message)
  mark(exception.new(message))
end

.mark(e) ⇒ Exception

Marks the given exception with the ServerError module.

This method extends the provided exception object with the ServerError module, effectively tagging it as a server-related error for consistent handling.

Parameters:

  • e (Exception)

    The exception object to be marked

Returns:

  • (Exception)

    The same exception object, now extended with ServerError



37
38
39
# File 'lib/unix_socks/server_error.rb', line 37

def self.mark(e)
  e.extend(self)
end