Permalink
Browse files

merge RACK_ENV and exception logging from bmizerany/master

  • Loading branch information...
rtomayko committed Nov 17, 2008
2 parents 971a185 + c08fbaf commit 18723bb8af047332c0a6a378205eaf872005a064
Showing with 12 additions and 2 deletions.
  1. +7 −1 ChangeLog
  2. +5 −1 lib/sinatra.rb
View
@@ -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
@@ -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

0 comments on commit 18723bb

Please sign in to comment.