Sha256: a88e870c734c4ae01caed8be5a6f469477fd6f19837b70264ae2e2a110f340bb

Contents?: true

Size: 751 Bytes

Versions: 8

Compression:

Stored size: 751 Bytes

Contents

module Kaui::EngineControllerUtil

  protected

  def get_layout
    layout ||= Kaui.config[:layout]
  end

  def as_string(e)
    if e.is_a?(KillBillClient::API::ResponseError)
      "Error #{e.response.code}: #{as_string_from_response(e.response.body)}"
    else
      e.message
    end
  end

  def as_string_from_response(response)
    error_message = response
    begin
      # BillingExceptionJson?
      error_message = JSON.parse response
    rescue => e
    end

    if error_message.respond_to? :[] and error_message['message'].present?
      # Likely BillingExceptionJson
      error_message = error_message['message']
    end
    # Limit the error size to avoid ActionDispatch::Cookies::CookieOverflow
    error_message[0..1000]
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kaui-0.11.0 app/controllers/kaui/engine_controller_util.rb
kaui-0.10.0 app/controllers/kaui/engine_controller_util.rb
kaui-0.9.0 app/controllers/kaui/engine_controller_util.rb
kaui-0.8.4 app/controllers/kaui/engine_controller_util.rb
kaui-0.8.3 app/controllers/kaui/engine_controller_util.rb
kaui-0.8.2 app/controllers/kaui/engine_controller_util.rb
kaui-0.8.1 app/controllers/kaui/engine_controller_util.rb
kaui-0.8.0 app/controllers/kaui/engine_controller_util.rb