Module: Ftpd::TranslateExceptions

Overview

This module translates exceptions to FileSystemError exceptions.

A disk file system (such as Ftpd::DiskFileSystem) is expected to raise only FileSystemError exceptions, but many common operations result in other exceptions such as SystemCallError. This module aids a disk driver in translating exceptions to FileSystemError exceptions.

In your file system, driver, include this module:

module MyDiskDriver
  include Ftpd::TranslateExceptions

in your constructor, register the exceptions that should be translated:

def initialize
  translate_exception SystemCallError
end

And register methods for translation:

def read(ftp_path)
   ...
end
translate_exceptions :read

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object



35
36
37
# File 'lib/ftpd/translate_exceptions.rb', line 35

def self.included(includer)
  includer.extend ClassMethods
end

Instance Method Details

#translate_exception(e) ⇒ Object

Add exception class e to the list of exceptions to be translated.



58
59
60
# File 'lib/ftpd/translate_exceptions.rb', line 58

def translate_exception(e)
  exception_translator.register_exception e
end