dblock/grape-on-rack

View on GitHub
api/rescue_from.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Acme
  class RescueFrom < Grape::API
    rescue_from :all do |e|
      Rack::Response.new([e.message], 500, 'Content-type' => 'text/error')
    end
    desc 'Raises an exception.' do
      success [{ code: 500, message: 'Error: Internal Server Error' }]
    end
    get :raise do
      raise 'Unexpected error.'
    end
  end
end