Sha256: f848a4d803ab9df58832a093f18317e4e7cdd1a8ba0e50eb22b55b65707a7eb2

Contents?: true

Size: 616 Bytes

Versions: 7

Compression:

Stored size: 616 Bytes

Contents

# frozen_string_literal: true

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 PermanentFileSystemError, e.message
      end
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ftpd-2.1.0 lib/ftpd/exception_translator.rb
ftpd-2.0.5 lib/ftpd/exception_translator.rb
ftpd-2.0.4 lib/ftpd/exception_translator.rb
ftpd-2.0.3 lib/ftpd/exception_translator.rb
ftpd-2.0.2 lib/ftpd/exception_translator.rb
ftpd-2.0.1 lib/ftpd/exception_translator.rb
ftpd-2.0.0 lib/ftpd/exception_translator.rb