Sha256: a9457e478836887e00758e2b1cf68c16e0e33f808ad2abe714de16c3b8020be9

Contents?: true

Size: 910 Bytes

Versions: 12

Compression:

Stored size: 910 Bytes

Contents

class FanforcePlugin::Sinatra
  require 'fanforce/errors'
  include Fanforce::Errors

  set :raise_errors, false
  set :show_exceptions, false

  error 400..600 do
    e = env['sinatra.error'] or (next response if e.nil?)

    if Object.const_defined?('Fanforce') and Fanforce.const_defined?('API') and e.is_a?(Fanforce::API::Error)
      errors = e.errors
    else
      errors = e.respond_to?(:public_errors) ? e.public_errors : []
      errors << {message: 'There has been an internal server error. Our developers have been notified.'} if errors.size == 0
    end

    admin_details = Fanforce::Errors.format_admin_details(e, errors)

    body = {errors: errors}
    body.merge!(admin_details.merge(backtrace: e.backtrace)).delete(:public_response) if params[:show_error_details] == '1' or FanforcePlugin.config.show_error_details

    status(e.respond_to?(:code ) ? e.code : 500) and json(body)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
fanforce-plugin-factory-0.11.0 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.10.0 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.7 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.6 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.5 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.4 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.3 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.2 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.1 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.9.0 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.8.2 lib/fanforce/plugin_factory/config/_error_handling.rb
fanforce-plugin-factory-0.8.1 lib/fanforce/plugin_factory/config/_error_handling.rb