Class: Fiona7::ErrorHandler
- Inherits:
-
Object
- Object
- Fiona7::ErrorHandler
- Defined in:
- lib/fiona7/controllers/rest_api/error_handler.rb
Constant Summary collapse
- HANDLED_ERRORS =
[ Reactor::Cm::MissingCredentials, Reactor::Cm::XmlRequestError, Reactor::NoWorkingVersion, Reactor::NotPermitted, Reactor::AlreadyReleased, Fiona7::TypeSystemError ]
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#locale ⇒ Object
Returns the value of attribute locale.
Instance Method Summary collapse
- #api_error ⇒ Object
-
#initialize(error, locale = Scrivito::Configuration.ui_locale || I18n.locale) ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
- #processed_message ⇒ Object
- #sdk_error ⇒ Object
Constructor Details
#initialize(error, locale = Scrivito::Configuration.ui_locale || I18n.locale) ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
14 15 16 17 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 14 def initialize(error, locale = Scrivito::Configuration.ui_locale || I18n.locale) self.error = error self.locale = locale end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
12 13 14 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 12 def error @error end |
#locale ⇒ Object
Returns the value of attribute locale.
12 13 14 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 12 def locale @locale end |
Instance Method Details
#api_error ⇒ Object
23 24 25 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 23 def api_error self. end |
#processed_message ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 27 def Rails.logger.error(self.error.inspect) Rails.logger.error(self.error.backtrace.join("\n")) case self.error when Reactor::Cm::XmlRequestError self.error..gsub(/\[[0-9]+\] /, '') when Reactor::Cm::MissingCredentials I18n.t(:"fiona7.errors.missing_credentials", locale: self.locale) when Reactor::NoWorkingVersion I18n.t(:"fiona7.errors.no_working_version", locale: self.locale) when Reactor::NotPermitted I18n.t(:"fiona7.errors.not_permitted", locale: self.locale) when Reactor::AlreadyReleased I18n.t(:"fiona7.errors.already_released", locale: self.locale) when Fiona7::TypeSystemError I18n.t(:"fiona7.errors.type_system", locale: self.locale) else self.error. end end |
#sdk_error ⇒ Object
19 20 21 |
# File 'lib/fiona7/controllers/rest_api/error_handler.rb', line 19 def sdk_error Scrivito::ApplicationError.new(self.) end |