Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[ErrorHandler] Add button to copy the path where error is thrown#40052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedFeb 1, 2021
Hey! You, my friend, deserve a BIG HUG for making this PR. To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
1da52a0 to057e2f5Comparenicolas-grekas commentedFeb 1, 2021
Dunno why@carsonbot closed this one. |
lmillucci commentedFeb 1, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think it was closed because I didn't read well the first comment I'm moving this to "ready for review" |
| <span class="trace-method"><?=$trace['function'];?></span> | ||
| <?php }?> | ||
| (line<?=$lineNumber;?>) | ||
| <button class="hidden" data-clipboard-text="<?phpechoimplode(\DIRECTORY_SEPARATOR,$filePathParts);?>">Copy path</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
should we suffix:$lineNumber? it works well in most editors AFAIK.
noniagriconomie commentedFeb 1, 2021
hello, isnt this "similar" tohttps://symfony.com/doc/current/reference/configuration/framework.html#ide? |
src/Symfony/Component/ErrorHandler/Resources/views/trace.html.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
yceruto commentedFeb 1, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yes, but not all IDEs support that feature, I think it would be worth it. 👍 on my side. |
4620b46 to18d25cdComparenicolas-grekas commentedFeb 4, 2021
Oh does the icon work in dark mode? Can you please update your screenshot? |
lmillucci commentedFeb 4, 2021
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(failures are false positives)
| } | ||
| /* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles*/ | ||
| var copyToClipboardElements= toggles[i].querySelectorAll('span[data-clipboard-text]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why usingfor (...) here and.forEach at line 40.
Same foraddEventListener(element vselement.addEventListener)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It would be even better to use event delegation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think that this code is actually useless because the click listener for toggle it is not attached to span elements. What do you think?
| var copyToClipboardElements= toggles[i].querySelectorAll('span[data-clipboard-text]') | ||
| for (var k=0; k<copyToClipboardElements.length; k++) { | ||
| addEventListener(copyToClipboardElements[k],'click',function(e) { | ||
| e.stopPropagation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
IMHO we could always stopPropagation (and not ONLY for items in SPAN/toggle). And moving this logic at line 44
Nyholm commentedFeb 6, 2021
I am with@noniagriconomie. I am also a bit confused =) The way I see it, on the error page, you see the relative path to each line in the stack trace. If you click at any of them it will open in PHPStorm... if you dont have it configured that way, you will get the file opened in the broswer and there you will see the absolute path. |
| <span class="trace-method"><?=$trace['function'];?></span> | ||
| <?php }?> | ||
| (line<?=$lineNumber;?>) | ||
| <span class="icon icon-copy hidden" data-clipboard-text="<?phpechoimplode(\DIRECTORY_SEPARATOR,$filePathParts).':'.$lineNumber;?>"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think thedata-clipboard-text should contain the full path to the file -not the formatted path that links to the IDE.
This means this should contain$trace['file'], html-escaped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm not sure about that... when running app in docker, absolute path is useless, while relative pat works in IDE, and console (when CWD=root of project)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Ah, you're right. We do have a way to map paths from docker to host, but it is bound to the IDE URLs. Can't we use that map somehow to compute absolute paths for the host?
nicolas-grekas commentedFeb 16, 2021
I think that allowing a copy/paste of the path of the file is interesting.
Then we would patch HtmlRenderer::getFileLink to also handle and forward the same optional argument. @lmillucci works for you? Can you please update the PR to account for all latest comments? |
lmillucci commentedFeb 17, 2021
I'm not sure about the behavior of the |
fabpot commentedJun 23, 2021
I would display the copy button only on hover to avoid having too many icons on the page. |
lmillucci commentedJul 16, 2021
fabpot commentedJul 25, 2021
@lmillucci Can you rebase on the current 5.4 branch to resolve the conflicts? Ping me when it's done so that I can merge this PR. Thank you. |
3bee7af tod1a60bbComparelmillucci commentedJul 26, 2021
@fabpot rebased 👍 |
d1a60bb to5779f86Comparefabpot commentedJul 26, 2021
Thank you@lmillucci. |




Uh oh!
There was an error while loading.Please reload this page.
As a developer I want to copy the path where an exception is thrown on my IDE to check what is the problem. At the moment I have to select the path on the error page and copy it. I think that this process could be simplified through a "copy path" button that copies the error path on the clipboard.
I was thinking about something like this:

(Page style should be improved)
Let me know what you think. If you think it is a good idea I could improve this PR