Class: Ftpd::ExceptionTranslator
- Inherits:
-
Object
- Object
- Ftpd::ExceptionTranslator
- Defined in:
- lib/ftpd/exception_translator.rb
Overview
Translate specific exceptions to FileSystemError.
This is not intended to be used directly, but via the TranslateExceptions module.
Instance Method Summary collapse
-
#initialize ⇒ ExceptionTranslator
constructor
A new instance of ExceptionTranslator.
-
#register_exception(e) ⇒ Object
Register an exception class.
-
#translate_exceptions ⇒ Object
Run a block, translating specific exceptions to FileSystemError.
Constructor Details
#initialize ⇒ ExceptionTranslator
Returns a new instance of ExceptionTranslator.
10 11 12 |
# File 'lib/ftpd/exception_translator.rb', line 10 def initialize @exceptions = [] end |
Instance Method Details
#register_exception(e) ⇒ Object
Register an exception class.
16 17 18 |
# File 'lib/ftpd/exception_translator.rb', line 16 def register_exception(e) @exceptions << e end |
#translate_exceptions ⇒ Object
Run a block, translating specific exceptions to FileSystemError.
22 23 24 25 26 27 28 |
# File 'lib/ftpd/exception_translator.rb', line 22 def translate_exceptions begin return yield rescue *@exceptions => e raise PermanentFileSystemError, e. end end |