Magento How-to: Improve Error Reporting

When an error occurs in Magento the user is sent to the /report/?id=... page. This is rarely what we want. As a developer we don’t want to be shuttled off to another page to read the error message. As a customer we don’t want the gory details about what happened.

Here’s how to get the error report via email and present the customer with a feedback form when the error happens. Explained.

When we are developing we can switch this redirection to the reporting screen off and let PHP tell us the problem there and then on the page by setting our development environment up correctly, more specifically by throwing the following in our index.php.

Mage::setIsDeveloperMode(true);

When we are live we don’t need the customer to try and figure out what went wrong, we just need to inform them that there was an error and make sure that we get the error reports.

Fortunately the guys at Varien have built some alternative functionality into the reporting feature, emailing us the entire report and providing the user with a contact form asking them to kindly explain what they were doing to produce this error.

Setting the reporter up to use this feature is simple.

  1. Find the `config.xml` file in the `/report` directory.
  2. Change `` from `print` to `email`.</li>
  3. Set `` to the email address that you would like the report to go to.</li>
  4. You're done.
  5. </ol> Then when we are live and would like to hide the error messages that we used during development for debugging can be disabled and the contact form presented by changing the developer mode to false in `index.php`. Editing the template for the report is just as easy. Take a look in the `/report/skin` folder for the usual.