Class: ActionController::Twirp::Error
- Inherits:
-
Object
- Object
- ActionController::Twirp::Error
- Defined in:
- lib/action_controller/twirp/error.rb
Overview
Class to generate Twirp::Error from an exception class and Config
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(exception) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(exception) ⇒ Error
Returns a new instance of Error.
10 11 12 13 14 15 16 |
# File 'lib/action_controller/twirp/error.rb', line 10 def initialize(exception) unless exception.is_a?(Exception) raise ArgumentError, 'Instance of Exception class can be specified' end @exception = exception end |
Instance Method Details
#generate ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/action_controller/twirp/error.rb', line 18 def generate if Config.exception_codes.key?(exception_name) code = Config.exception_codes[exception_name] = Config..call(exception) = Config..call(exception) ::Twirp::Error.public_send(code, , ) else ::Twirp::Error.internal_with(exception) end rescue StandardError => e ::Twirp::Error.internal_with(e) end |