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.
12 13 14 |
# File 'lib/ftpd/exception_translator.rb', line 12 def initialize @exceptions = [] end |
Instance Method Details
#register_exception(e) ⇒ Object
Register an exception class.
18 19 20 |
# File 'lib/ftpd/exception_translator.rb', line 18 def register_exception(e) @exceptions << e end |
#translate_exceptions ⇒ Object
Run a block, translating specific exceptions to FileSystemError.
24 25 26 27 28 29 30 |
# File 'lib/ftpd/exception_translator.rb', line 24 def translate_exceptions begin return yield rescue *@exceptions => e raise PermanentFileSystemError, e. end end |