Viewing Error Backtraces for Ambiguous Error Messages

There are many times when working with the Magento front end that I get a very ambiguous error message. Here is a screenshot of the type of error I’m talking about:
Error Message

I usually just search the entire codebase for the error message code, locate the place where the exception is getting caught, and then temporarily modify the code to Mage::log() the following data: $e->getMessage(), $e->getTraceAsString(), etc…

I just came across an exception handler in the Mage_Checkout_MultishippingController class that passed the generic exception message as well as the Exception class itself to Mage::getSingleton(‘checkout/session’)->addException(). Here’s the code (from line 219 of the containing file):

        catch (Exception $e) {
            Mage::getSingleton('checkout/session')->addException(
                $e,
                Mage::helper('checkout')->__('Data saving problem')
            );
            $this->_redirect('*/*/addresses');
        }

 

[cta prefix=”Related:” count=”1″][/cta]

 

I dug into the Mage::getSingleton(‘checkout/session’)->addException() class and realized that it logged the exception code to the var/logs/exception.log file (it only logs the exception if logging is enabled in System > Preferences > Developer). This means that instead of locating and hacking up core files to see exceptions that are thrown, in a lot of cases, you can just monitor the contents of the exception.log file.

If you’re developing on a Mac machine, you can monitor the contents of the exception.log file using the Console app. If you’re on a Linux box, you can use “tail -f var/log/exception.log” to monitor the contents of this file.

Hopefully this helps you in your debugging efforts!

Share it

Topics

Related Posts

Everything You Need to Know About Updating to Google Analytics 4

Classy Llama is Proud to be a Sponsor of Signifyd’s #FLOWSummit2023

Classy Llama Earns 2 New Workplace Awards from Comparably.com

Contact Us