Module: Ftpd::TranslateExceptions
- Includes:
- Memoizer
- Included in:
- DiskFileSystem::Append, DiskFileSystem::Base, DiskFileSystem::Delete, DiskFileSystem::List, DiskFileSystem::Mkdir, DiskFileSystem::Read, DiskFileSystem::Rename, DiskFileSystem::Rmdir, DiskFileSystem::Write
- Defined in:
- lib/ftpd/translate_exceptions.rb
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
-
#translate_exception(e) ⇒ Object
Add exception class e to the list of exceptions to be translated.
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 |