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


33
34
35
# File 'lib/ftpd/translate_exceptions.rb', line 33

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.


55
56
57
# File 'lib/ftpd/translate_exceptions.rb', line 55

def translate_exception(e)
  exception_translator.register_exception e
end