Nick Jones

a magento developer at Meanbee (@nickj89) and uk magento expert based in Bath

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 <action> from print to email.
  3. Set <email> to the email address that you would like the report to go to.
  4. You’re done.

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.

11 Responses to Magento How-to: Improve Error Reporting

  1. Luke Hamilton says:

    Hey Nick,

    Do you also know if there is a way to override the report’s skins so whenever one does an upgrade they dont over write the custom reports skins?

    • Nick says:

      I really don’t think that is possible as it lives in the /report/ directory. Haven’t had time to look into it so I may be wrong. I remember seeing that report is entirely independent from themes which is annoying. Maybe there’s a way to override it, although I also remember seeing a reference to report in Mage.php which is final’d.

      Just thinking out loud.

  2. To change the default skin for the email error reporting page:

    Put a ‘design.xml’ file into the ‘/report/’ directory:

    your-template.phtml

    Put the ‘your-template.phtml’ into the ‘/report/skin/default/’ directory (or make a copy of the ‘index.phtml’ there) and customize it to your liking.

    The URL Request also carries a [s] part (for ‘site’) which is (our guess) the package name of the whole site defined in the configuration. Not sure however, as not having tested this.

    You may just check the code of ‘/report/index.php’ for the underlying code on this one.

    • Divyesh K says:

      how can I customize error page in Magento Enterprise Magento ver. 1.7.0.0 ?
      because in this version , report directory has removed and add one directory called "Error" at root directory

  3. Sorry, just realized that XML is being stripped on the posts here…

    ‘design.xml’:
    ———-

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <design>
    <template>your-template.phtml</template>
    </design>

  4. Pingback: Magento How-to: Custom Error Page Design | Nick Says

  5. drew says:

    thanks for the tip. really like this and everything works great for me except that the emails show up in my spam folder. i believe its due it coming from an unknown sender – no name, no email address.

    do you know where i can configure these things?

  6. Jakub says:

    Big thanks to you for this great time-saving trick. Cheers!

  7. Amin says:

    Excellent post mate.

    Thank you very much.
    Amin

  8. Molecule says:

    Nice one sharing this, ta.

  9. Pankaj says:

    Thank you for posting very good post.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">