Sha256: 338216bbf3dbed00663b5469daa3d381255cb45a6f6960e57ec1df68f986c31b

Contents?: true

Size: 1014 Bytes

Versions: 67

Compression:

Stored size: 1014 Bytes

Contents

class FanforceApp::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)
    Bugsnag.notify(e, admin_details.merge(app_id: FanforceApp._id)) if FanforceApp.config.bugsnag_enabled?

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

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

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
fanforce-app-factory-0.25.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.24.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.24.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.23.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.23.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.22.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.22.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.21.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.20.2 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.20.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.20.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.19.4 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.19.3 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.19.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.19.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.18.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.17.2 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.17.1 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.17.0 lib/fanforce/app_factory/config/_error_handling.rb
fanforce-app-factory-0.16.1 lib/fanforce/app_factory/config/_error_handling.rb