Skip to content

Render all exceptions on error page when in debug mode#10964

Merged
rdeutz merged 7 commits intojoomla:stagingfrom
mbabker:stacked-exceptions
Aug 19, 2016
Merged

Render all exceptions on error page when in debug mode#10964
rdeutz merged 7 commits intojoomla:stagingfrom
mbabker:stacked-exceptions

Conversation

@mbabker
Copy link
Copy Markdown
Contributor

@mbabker mbabker commented Jun 29, 2016

Summary of Changes

An Exception may have been chained to include additional errors. If this is the case, the chained errors may help with debugging an issue. So when in debug mode, I suggest that our error templates display the error data for all Exceptions.

Testing Instructions

Enable debug mode.

You'll be testing each core template, in both the site and admin apps, and you'll also want to test the system templates (default error pages), to do that you'll need to temporarily rename the error.php file in your active template to something else. Remember to give it back its original name when finished testing this.

Trigger the error page with a chained Exception (when creating an Exception object, pass the "previous" Exception as the third constructor argument). The previous Exception(s) should display when in debug mode with their stack trace after the main error is rendered.

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-staging labels Jun 29, 2016
@ggppdk
Copy link
Copy Markdown
Contributor

ggppdk commented Jun 29, 2016

Trigger the error page with a chained Exception (when creating an Exception object, pass the "previous" Exception as the third constructor argument).

Can you make this testing step to be more detailed, e.g. provide an example of file/line to change to trigger such an error, i don't understand it

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Jun 29, 2016

throw new Exception('Top Exception', 500, new Exception('Nested Exception'));

@yvesh
Copy link
Copy Markdown
Member

yvesh commented Jun 29, 2016

For me it does not output the "Nested Exception" message, but two times the parent one (Top Exception in your example).

screenshot 2016-06-29 21 02 24

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Jun 29, 2016

I left all these comments about using $this->_error versus $this->error and I still managed to screw that up. It's fixed now.

@yvesh
Copy link
Copy Markdown
Member

yvesh commented Jun 29, 2016

Yep working now. Imo it's a nice improvement, there are some valid use cases for nested exceptions 👍

@ggppdk
Copy link
Copy Markdown
Contributor

ggppdk commented Jun 29, 2016

Yes, it shows both correctly,

not relevant to this topic, i hope something is decided for getFile() getLine() too that will show the line that the exception occured, thanks

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Aug 13, 2016

No longer RFC, changes made to all core templates, please test.

@andrepereiradasilva
Copy link
Copy Markdown
Contributor

andrepereiradasilva commented Aug 15, 2016

@mbabker the test went well. But one thing is missing. I tested in admin templates (isis, hathor and system) and i get a JERROR_LAYOUT_PREVIOUS_ERROR not translated.

image

So i think you need to add that language var also to https://github.com/joomla/joomla-cms/blob/staging/administrator/language/en-GB/en-GB.ini

@andrepereiradasilva
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on b9bfda1


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10964.

@yvesh
Copy link
Copy Markdown
Member

yvesh commented Aug 15, 2016

@mbabker How about moving generating that output to a helper / JLayout file - so much duplicate code? :(

JHtmlError for example

@mbabker
Copy link
Copy Markdown
Contributor Author

mbabker commented Aug 15, 2016

It's appropriate in the template. Otherwise there will have to be additional public APIs to do the same. Plus, there should be zero output generated by helper methods, meaning the helper method would have to call JLayout, and now to override markup that was originally created in the template (either directly or through a method called by the template) you have to override a layout file. This is the cleanest approach.

@yvesh
Copy link
Copy Markdown
Member

yvesh commented Aug 16, 2016

I have tested this item ✅ successfully on b9bfda1

Thank you for the explanation


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10964.

@rdeutz rdeutz added this to the Joomla 3.6.3 milestone Aug 16, 2016
@jeckodevelopment
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10964.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 17, 2016
@rdeutz rdeutz merged commit 09cea21 into joomla:staging Aug 19, 2016
ggppdk pushed a commit to ggppdk/joomla-cms that referenced this pull request Aug 19, 2016
* Render all exceptions on error page when in debug mode

* Displaying wrong error message

* Small logic tweak so Exceptions aren't skipped

* Stacked exceptions for all templates

* Add language string
@brianteeman brianteeman removed the RTC This Pull Request is Ready To Commit label Aug 20, 2016
roland-d pushed a commit to roland-d/joomla-cms that referenced this pull request Sep 11, 2016
* Render all exceptions on error page when in debug mode

* Displaying wrong error message

* Small logic tweak so Exceptions aren't skipped

* Stacked exceptions for all templates

* Add language string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants