Module: WebSocket::ExceptionHandler::ClassMethods
- Defined in:
- lib/websocket/exception_handler.rb
Instance Method Summary collapse
-
#rescue_method(method_name, options = {}) ⇒ Object
Rescue from WebSocket::Error errors.
Instance Method Details
#rescue_method(method_name, options = {}) ⇒ Object
Rescue from WebSocket::Error errors.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/websocket/exception_handler.rb', line 18 def rescue_method(method_name, = {}) define_method "#{method_name}_with_rescue" do |*args| begin send("#{method_name}_without_rescue", *args) rescue WebSocket::Error => e self.error = e..to_sym WebSocket.should_raise ? raise : [:return] end end alias_method "#{method_name}_without_rescue", method_name alias_method method_name, "#{method_name}_with_rescue" end |