Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merge RACK_ENV and exception logging from bmizerany/master

  • Loading branch information...
commit 18723bb8af047332c0a6a378205eaf872005a064 2 parents 971a185 + c08fbaf
@rtomayko rtomayko authored
Showing with 12 additions and 2 deletions.
  1. +7 −1 ChangeLog
  2. +5 −1 lib/sinatra.rb
View
8 ChangeLog
@@ -1,4 +1,10 @@
-= 0.3.3
+= 0.3.3 (Unreleased)
+
+ * Log unhandled exception backtraces to rack.errors.
+
+ * Use RACK_ENV environment variable to establish Sinatra
+ environment when given. Thin sets this when started with
+ the -e argument.
* BUG: use_in_file_templates! failes with CR/LF (#45)
View
6 lib/sinatra.rb
@@ -929,7 +929,7 @@ def self.default_options
:run => true,
:port => 4567,
:host => '0.0.0.0',
- :env => :development,
+ :env => (ENV['RACK_ENV'] || :development).to_sym,
:root => root,
:views => root + '/views',
:public => root + '/public',
@@ -1266,6 +1266,10 @@ def dispatch(env)
end
body = returned.to_result(context)
rescue => e
+ msg = "#{e.class.name} - #{e.message}:"
+ msg << "\n #{e.backtrace.join("\n ")}"
+ request.env['rack.errors'] << msg
+
request.env['sinatra.error'] = e
context.status(500)
raise if options.raise_errors && e.class != NotFound
Please sign in to comment.
Something went wrong with that request. Please try again.