Sha256: 7fbb7d809f061b77139d3dd934363c7fdaa9bff380f6950ca0c74fc2fc2a38a7

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

module Ftpd

  # Translate specific exceptions to FileSystemError.
  #
  # This is not intended to be used directly, but via the
  # TranslateExceptions module.

  class ExceptionTranslator

    def initialize
      @exceptions = []
    end

    # Register an exception class.

    def register_exception(e)
      @exceptions << e
    end

    # Run a block, translating specific exceptions to FileSystemError.

    def translate_exceptions
      begin
        return yield
      rescue *@exceptions => e
        raise FileSystemError, e.message
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ftpd-0.2.0 lib/ftpd/exception_translator.rb
ftpd-0.1.1 lib/ftpd/exception_translator.rb