module Fiona7 class ErrorHandler HANDLED_ERRORS = [ Reactor::Cm::MissingCredentials, Reactor::Cm::XmlRequestError, Reactor::NoWorkingVersion, Reactor::NotPermitted, Reactor::AlreadyReleased, Fiona7::TypeSystemError ] attr_accessor :error, :locale def initialize(error, locale = Scrivito::Configuration.ui_locale || I18n.locale) self.error = error self.locale = locale end def sdk_error Scrivito::ApplicationError.new(self.processed_message) end def api_error self.processed_message end def processed_message Rails.logger.error(self.error.inspect) Rails.logger.error(self.error.backtrace.join("\n")) case self.error when Reactor::Cm::XmlRequestError self.error.message.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.message end end end end