Konstantin
> --
> You received this message because you are subscribed to the Google Groups "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.
this does not work, it only prints following information
[[Rack::Runtime, [], nil]]
and finally I found a way for this, throw exception and print
stackstrace, example as follows
require 'rubygems'
gem 'sinatra'
require 'sinatra'
enable :sessions
use Rack::Runtime
get '/' do
begin
raise 'hello'
rescue => e
content_type 'text/plain'
res = ''
for x in e.backtrace
res << x << "\n"
end
res
end
end
it will print following information:
hi.rb:10:in `GET /'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1063:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1063:in
`compile!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:649:in
`instance_eval'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:649:in
`route_eval'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:633:in
`route!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:681:in
`process_route'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:678:in
`catch'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:678:in
`process_route'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:632:in
`route!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:631:in
`each'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:631:in
`route!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:766:in
`dispatch!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:559:in
`call!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in
`instance_eval'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in
`invoke'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in
`catch'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:731:in
`invoke'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:559:in
`call!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:544:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/runtime.rb:17:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/showexceptions.rb:24:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/methodoverride.rb:24:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/commonlogger.rb:18:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/session/cookie.rb:37:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1173:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1199:in
`synchronize'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1173:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/content_length.rb:13:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/chunked.rb:15:in
`call'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/connection.rb:84:in
`pre_process'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/connection.rb:82:in
`catch'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/connection.rb:82:in
`pre_process'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/connection.rb:57:in
`process'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/connection.rb:42:in
`receive_data'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in
`run_machine'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in
`run'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/backends/base.rb:61:in
`start'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/thin-1.2.8/lib/thin/server.rb:159:in
`start'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/rack-1.2.1/lib/rack/handler/thin.rb:14:in
`run'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/base.rb:1144:in
`run!'
/home/lidb/.rvm/gems/ruby-1.8.7-p330/gems/sinatra-1.1.3/lib/sinatra/main.rb:25
hi.rb:21
> Cheers,
> Ben
>
> --
> You received this message because you are subscribed to the Google Groups
> "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to
> sinatrarb+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sinatrarb?hl=en.
>
--
Best Regards
LI Daobing
this does not work, it only prints following informationOn Wed, Mar 9, 2011 at 21:01, Ben Lovell <benjami...@gmail.com> wrote:
> On 9 March 2011 12:55, LI Daobing <lida...@gmail.com> wrote:
>>
>> Hello,
>> when I use rails, I can print the middleware list with "rake middleware"
>> or "Rails.configuration.middleware", but I can't find a way to print this in
>> sinatra.
>> I have tried Sinatra::Application.middleware, but it always return a empty
>> Array
>>
>
> Sinatra::Application.instance_variable_get("@middleware")
[[Rack::Runtime, [], nil]]
...
got it thanks