aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
diff options
context:
space:
mode:
authorRyan Dao <daoduyducduong@gmail.com>2014-07-30 15:35:47 +0700
committerRyan Dao <daoduyducduong@gmail.com>2014-08-08 15:04:55 +0700
commit1ed264bc60f3c76ba7fab339806fa1757702a46b (patch)
treeaa266283d80c8c7f6cad435b190f9f8204a36c44 /actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
parent30529dc00f96777c325dff496930f560fb9d59e9 (diff)
downloadrails-1ed264bc60f3c76ba7fab339806fa1757702a46b.tar.gz
rails-1ed264bc60f3c76ba7fab339806fa1757702a46b.tar.bz2
rails-1ed264bc60f3c76ba7fab339806fa1757702a46b.zip
Retrieve source code for the entire stack trace
Provide the ability to extract the source code of the entire exception stack trace, not just the frame raising the error. This improves debugging capability of the error page, especially for framework-related errors.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/exception_wrapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/exception_wrapper.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
index 2326bb043a..b98b553c38 100644
--- a/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
+++ b/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb
@@ -61,12 +61,15 @@ module ActionDispatch
end
def source_extract
- if application_trace && trace = application_trace.first
- file, line, _ = trace.split(":")
- @file = file
- @line_number = line.to_i
- source_fragment(@file, @line_number)
- end
+ exception.backtrace.map do |trace|
+ file, line = trace.split(":")
+ line_number = line.to_i
+ {
+ code: source_fragment(file, line_number),
+ file: file,
+ line_number: line_number
+ }
+ end if exception.backtrace
end
private
@@ -110,7 +113,7 @@ module ActionDispatch
def expand_backtrace
@exception.backtrace.unshift(
@exception.to_s.split("\n")
- ).flatten!
+ ).flatten!
end
end
end