Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ac317e77
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac317e77
编写于
2月 16, 2016
作者:
R
Richard Schneeman
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23203 from vipulnsward/22979-show-tags-on-exception
WIP: Errors in logs should show log tags as well.
上级
b0b61b62
632938cf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
12 deletion
+16
-12
actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
...onpack/lib/action_dispatch/middleware/debug_exceptions.rb
+11
-7
actionview/lib/action_view/template/error.rb
actionview/lib/action_view/template/error.rb
+2
-2
actionview/test/template/render_test.rb
actionview/test/template/render_test.rb
+3
-3
未找到文件。
actionpack/lib/action_dispatch/middleware/debug_exceptions.rb
浏览文件 @
ac317e77
...
...
@@ -149,22 +149,26 @@ def render(status, body, format)
def
log_error
(
request
,
wrapper
)
logger
=
logger
(
request
)
return
unless
logger
exception
=
wrapper
.
exception
trace
=
wrapper
.
application_trace
trace
=
wrapper
.
framework_trace
if
trace
.
empty?
ActiveSupport
::
Deprecation
.
silence
do
message
=
"
\n
#{
exception
.
class
}
(
#{
exception
.
message
}
):
\n
"
message
<<
exception
.
annoted_source_code
.
to_s
if
exception
.
respond_to?
(
:annoted_source_code
)
message
<<
" "
<<
trace
.
join
(
"
\n
"
)
logger
.
fatal
(
"
#{
message
}
\n\n
"
)
logger
.
fatal
" "
logger
.
fatal
"
#{
exception
.
class
}
(
#{
exception
.
message
}
):"
log_array
logger
,
exception
.
annoted_source_code
if
exception
.
respond_to?
(
:annoted_source_code
)
logger
.
fatal
" "
log_array
logger
,
trace
end
end
def
logger
(
request
)
request
.
logger
||
stderr_logger
def
log_array
logger
,
array
array
.
map
{
|
line
|
logger
.
fatal
line
}
end
def
logger
request
request
.
logger
||
ActionView
::
Base
.
logger
||
stderr_logger
end
def
stderr_logger
...
...
actionview/lib/action_view/template/error.rb
浏览文件 @
ac317e77
...
...
@@ -135,13 +135,13 @@ def source_location
end
def
formatted_code_for
(
source_code
,
line_counter
,
indent
,
output
)
start_value
=
(
output
==
:html
)
?
{}
:
""
start_value
=
(
output
==
:html
)
?
{}
:
[]
source_code
.
inject
(
start_value
)
do
|
result
,
line
|
line_counter
+=
1
if
output
==
:html
result
.
update
(
line_counter
.
to_s
=>
"%
#{
indent
}
s %s
\n
"
%
[
""
,
line
])
else
result
<<
"%
#{
indent
}
s: %s
\n
"
%
[
line_counter
,
line
]
result
<<
"%
#{
indent
}
s: %s"
%
[
line_counter
,
line
]
end
end
end
...
...
actionview/test/template/render_test.rb
浏览文件 @
ac317e77
...
...
@@ -226,13 +226,13 @@ def test_render_partial_with_errors
assert_match
%r!method.*doesnt_exist!
,
e
.
message
assert_equal
""
,
e
.
sub_template_message
assert_equal
"1"
,
e
.
line_number
assert_equal
"1: <%= doesnt_exist %>"
,
e
.
annoted_source_code
.
strip
assert_equal
"1: <%= doesnt_exist %>"
,
e
.
annoted_source_code
[
0
]
.
strip
assert_equal
File
.
expand_path
(
"
#{
FIXTURE_LOAD_PATH
}
/test/_raise.html.erb"
),
e
.
file_name
end
def
test_render_error_indentation
e
=
assert_raises
(
ActionView
::
Template
::
Error
)
{
@view
.
render
(
:partial
=>
"test/raise_indentation"
)
}
error_lines
=
e
.
annoted_source_code
.
split
(
"
\n
"
)
error_lines
=
e
.
annoted_source_code
assert_match
%r!error
\s
here!
,
e
.
message
assert_equal
"11"
,
e
.
line_number
assert_equal
" 9: <p>Ninth paragraph</p>"
,
error_lines
.
second
...
...
@@ -252,7 +252,7 @@ def test_render_file_with_errors
assert_match
%r!method.*doesnt_exist!
,
e
.
message
assert_equal
""
,
e
.
sub_template_message
assert_equal
"1"
,
e
.
line_number
assert_equal
"1: <%= doesnt_exist %>"
,
e
.
annoted_source_code
.
strip
assert_equal
"1: <%= doesnt_exist %>"
,
e
.
annoted_source_code
[
0
]
.
strip
assert_equal
File
.
expand_path
(
"
#{
FIXTURE_LOAD_PATH
}
/test/_raise.html.erb"
),
e
.
file_name
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录