10000 feature #26671 More compact display of vendor code in exception pages… · symfony/symfony@05b9f64 · GitHub
[go: up one dir, main page]

Skip to content

Commit 05b9f64

Browse files
committed
feature #26671 More compact display of vendor code in exception pages (javiereguiluz)
This PR was squashed before being merged into the 4.1-dev branch (closes #26671). Discussion ---------- More compact display of vendor code in exception pages | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23144 | License | MIT | Doc PR | - I like the general idea proposed in #23152 ... but I don't like the implementation ... so this PR is an alternative implementation. **UPDATE**: the proposed feature has been completely redesigned. See #26671 (comment) ~~The idea is to **hide by default all information that comes from "vendors"** (`vendor/` or `var/cache/` dir) because that code is out of your reach and you can't change it to fix your error.~~ ~~In practice, each exception trace now would display a `Hide vendors` option enabled by default:~~ <details> <summary>Click here to view the outdated images</summary> ![hide-vendors](https://user-images.githubusercontent.com/73419/37895113-a9d942bc-30e0-11e8-9ff4-191dcb057d60.png) It works like a toggle ... and it's compatible with the overall toggle of each trace header: ![hide-vendors](https://user-images.githubusercontent.com/73419/37895137-b9e8d406-30e0-11e8-82bd-5729d32aaa63.gif) When exceptions are complex, the amount of noise removed is massive: ## Before ![before](https://user-images.githubusercontent.com/73419/37895233-f9170eea-30e0-11e8-8c21-c514007d44d2.png) ## After ![after](https://user-images.githubusercontent.com/73419/37895240-fc2e50c0-30e0-11e8-9e5a-b7a73ba57b47.png) </details> Commits ------- 510b05f More compact display of vendor code in exception pages
2 parents 209b32f + 510b05f commit 05b9f64

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<div class="trace-line-header break-long-words {{ trace.file|default(false) ? 'sf-toggle' }}" data-toggle-selector="#trace-html-{{ prefix }}-{{ i }}" data-toggle-initial="{{ _display_code_snippet ? 'display' }}">
1+
<div class="trace-line-header break-long-words {{ trace.file|default(false) ? 'sf-toggle' }}" data-toggle-selector="#trace-html-{{ prefix }}-{{ i }}" data-toggle-initial="{{ style == 'expanded' ? 'display' }}">
22
{% if trace.file|default(false) %}
33
<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square.svg') }}</span>
44
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square.svg') }}</span>
55
{% endif %}
66

7-
{% if trace.function %}
7+
{% if style != 'compact' and trace.function %}
88
<span class="trace-class">{{ trace.class|abbr_class }}</span>{% if trace.type is not empty %}<span class="trace-type">{{ trace.type }}</span>{% endif %}<span class="trace-method">{{ trace.function }}</span><span class="trace-arguments">({{ trace.args|format_args }})</span>
99
{% endif %}
1010

@@ -17,6 +17,7 @@
1717
<span class="block trace-file-path">
1818
in
1919
<a href="{{ file_link }}">{{ file_path_parts[:-1]|join(constant('DIRECTORY_SEPARATOR')) }}{{ constant('DIRECTORY_SEPARATOR') }}<strong>{{ file_path_parts|last }}</strong></a>
20+
{%- if style == 'compact' and trace.function %}<span class="trace-type">{{ trace.type }}</span><span class="trace-method">{{ trace.function }}</span>{% endif %}
2021
(line {{ line_number }})
2122
</span>
2223
{% endif %}

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<div class="trace-head">
44
<span class="sf-toggle" data-toggle-selector="#trace-html-{{ index }}" data-toggle-initial="{{ expand ? 'display' }}">
55
<h3 class="trace-class">
6+
<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square-o.svg') }}</span>
7+
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square-o.svg') }}</span>
8+
69
<span class="trace-namespace">
710
{{ exception.class|split('\\')|slice(0, -1)|join('\\') }}
811
{{- exception.class|split('\\')|length > 1 ? '\\' }}
912
</span>
1013
{{ exception.class|split('\\')|last }}
11-
12-
<span class="icon icon-close">{{ include('@Twig/images/icon-minus-square-o.svg') }}</span>
13-
<span class="icon icon-open">{{ include('@Twig/images/icon-plus-square-o.svg') }}</span>
1414
</h3>
1515

1616
{% if exception.message is not empty and index > 1 %}
@@ -22,10 +22,11 @@
2222
<div id="trace-html-{{ index }}" class="sf-toggle-content">
2323
{% set _is_first_user_code = true %}
2424
{% for i, trace in exception.trace %}
25-
{% set _display_code_snippet = _is_first_user_code and ('/vendor/' not in trace.file) and ('/var/cache/' not in trace.file) and (trace.file is not empty) %}
25+
{% set _is_vendor_trace = trace.file is not empty and ('/vendor/' in trace.file or '/var/cache/' in trace.file) %}
26+
{% set _display_code_snippet = _is_first_user_code and not _is_vendor_trace %}
2627
{% if _display_code_snippet %}{% set _is_first_user_code = false %}{% endif %}
27-
<div class="trace-line">
28-
{{ include('@Twig/Exception/trace.html.twig', { prefix: index, i: i, trace: trace, _display_code_snippet: _display_code_snippet }, with_context = false) }}
28+
<div class="trace-line {{ _is_vendor_trace ? 'trace-from-vendor' }}">
29+
{{ include('@Twig/Exception/trace.html.twig', { prefix: index, i: i, trace: trace, style: _is_vendor_trace ? 'compact' : _display_code_snippet ? 'expanded' }, with_context = false) }}
2930
</div>
3031
{% endfor %}
3132
</div>

src/Symfony/Bundle/TwigBundle/Resources/views/exception.css.twig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,18 @@ header .container { display: flex; justify-content: space-between; }
9090
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }
9191

9292
.trace + .trace { margin-top: 30px; }
93-
.trace-head { background-color: #e0e0e0; padding: 10px; }
93+
.trace-head { background-color: #e0e0e0; padding: 10px; position: relative; }
9494
.trace-head .trace-class { color: #222; font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; }
9595
.trace-head .trace-namespace { color: #999; display: block; font-size: 13px; }
9696
.trace-head .icon { position: absolute; right: 0; top: 0; }
9797
.trace-head .icon svg { height: 24px; width: 24px; }
9898

99-
.trace-details { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; }
99+
.trace-details { background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; table-layout: fixed; }
100100

101101
.trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; }
102-
.trace-details { table-layout: fixed; }
102+
103103
.trace-line { position: relative; padding-top: 8px; padding-bottom: 8px; }
104+
.trace-line + .trace-line { border-top: 1px solid #e0e0e0; }
104105
.trace-line:hover { background: #F5F5F5; }
105106
.trace-line a { color: #222; }
106107
.trace-line .icon { opacity: .4; position: absolute; left: 10px; top: 11px; }

0 commit comments

Comments
 (0)
0