I'm sorry if this is a bleedingly obvious question. I think I am going crazy.
I have code that I know is stopping at a specific point. The file I am looking at is app/code/core/Mage/Downloadable/Helper/Download.php
(NB. yes, I totally understand and agree that I should not be fiddling with core, but this is just my playing around in a locally installed Magento, and going to be reverted back afterwards)
The line that the code is breaking at is:
if (!isset($urlProp['scheme']) || strtolower($urlProp['scheme'] != 'http')) {
Mage::throwException(Mage::helper('downloadable')->__('Invalid download URL scheme.'));
}
It is not getting past the Mage::throwException line. I know this because I am logging comments (to my own custom log file) before and after that line, and only the comments before that line are being logged.
My question is not why I am getting this specific error for this specific bit of code – but why I am not seeing the Invalid download URL scheme.
error ANYWHERE. It is not appearing in my browser when the code is run, and it is not appearing in exception.log (that file actually does not exist in var/log – nor does system.log). Am I right in thinking that I should be seeing that error somewhere? It is making debugging very difficult!
Here's what I've done to try and get errors showing:
- In System/Configuration/Advanced/Developer/Log Settings – Set "Enabled" to "Yes".
- In
index.php
, I have gotMage::setIsDeveloperMode(true);
- In
index.php
, I have gotini_set('display_errors', 1);
I know this is working because if I force a syntax error, I get an error in browser. - In
/errors
, I have renamedlocal.xml.sample
tolocal.xml
(not sure what this one does but have seen it in a couple of articles to do with exception printing). - I have checked that
var/log
is writable. I know this is working because there is another custom log file that I am writing to successfully withMage::log
Any ideas greatly welcomed! What should Mage::throwException
actually be doing – printing in browser, or in exception.log, or both?
I am using Magento CE 1.9.0.1 on localhost (using a Mac with MAMP).
Best Answer
It
throw
s an exception, nothing more, nothing less.That means, any code higher up the stack may
catch
it and do whatever it decides to. Typically it's one or more of the following:Mage::logException()
(this is where it gets added toexception.log
)My guess is on (3) in your case. Get a debugger installed on your development system, set a breakpoint at the
Mage::throwException()
line and you will find out. And I actually highly recommend looking at the core. It's one of the best resources to learn Magento development.Update:
if you see a page with something like "An error occured, please contact the store owner" and a long number, this is what Magento shows you for uncaught exceptions. You will find the exception message and stack trace logged in
var/report/HERE_COMES_THE_NUMBER